F.interpolate
applies the interpolation in the temporal/spatial/volumetric dimensions.
In your case it would accept a single value:
x = torch.randn(8, 28, 161)
out = F.interpolate(x, size=140)
print(out.shape)
> torch.Size([8, 28, 140])
Since you want to interpolate in the channel dimension, you could permute the tensor and apply the interpolation on it:
x = torch.randn(8, 28, 161)
x = x.permute(0, 2, 1)
x = F.interpolate(x, size=27)
x = x.permute(0, 2, 1)
print(x.shape)
> torch.Size([8, 27, 161])