Thanks so much… I have a 3d  data and I create a  tensor like this:
torch.Size([1, 240, 240, 240])
When I try  to use grid sample I have this error. Seem I can’t use for only 3D data it is correct?
flow = torch.Tensor([1,128,128,128])
torch.nn.functional.grid_sample(data['data'],flow, mode='bilinear', padding_mode='zeros', align_corners=None)
untimeError: grid_sampler(): expected 4D or 5D input and grid with same number of dimensions, but got input with sizes [1, 240, 240, 240] and grid with sizes [4]