torch.nn.functional.grid_sample
torch.nn.functional.grid_sample(input, grid, mode='bilinear', padding_mode='zeros', align_corners=None)
Given an "input" and a flow-field "grid", computes the "output"
   using "input" values and pixel locations from "grid".
Currently, only spatial (4-D) and volumetric (5-D) "input" are
   supported.
In the spatial (4-D) case, for "input" with shape (N, C,
   H_\text{in}, W_\text{in}) and "grid" with shape (N, H_\text{out},
   W_\text{out}, 2), the output will have shape (N, C, H_\text{out},
   W_\text{out}).
For each output location "output[n, :, h, w]", the size-2 vector
   "grid[n, h, w]" specifies "input" pixel locations "x" and "y",
   which are used to interpolate the output value "output[n, :, h,
   w]". In the case of 5D inputs, "grid[n, d, h, w]" specifies the
   "x", "y", "z" pixel locations for interpolating "output[n, :, d, h,
   w]". "mode" argument specifies "nearest" or "bilinear"