You can use it for 4-D and 5-D data (your case, if you unsqueeze a fake channel dimension).
However, the grid shape should be [N, H_out, W_out, 2], while you are passing 4 values.
Here is a small example of the usage:
N, C, H, W = 1, 24, 24, 24
x = torch.arange(N*C*H*W).view(N, 1, C, H, W).float()
d = torch.linspace(-1, 1, 12)
meshx, meshy, meshz = torch.meshgrid((d, d, d))
grid = torch.stack((meshx, meshy, meshz), 3)
grid = grid.unsqueeze(0) # add batch dim
out = F.grid_sample(x, grid, align_corners=True)
You might want to check, if the order of the meshes is correct for your use case.