Exact displacement of each pixel on using grid_sample

I have input image and grid passed in torch.nn.functional.grid_sample(). Now if I have a random pixel location (x, y) from the input image, how can I find out its location in the output of grid_sample().

Would this be sufficient for finding new location of pixel:
ix = ((ix + 1) / 2) * (IW-1);
iy = ((iy + 1) / 2) * (IH-1);
as mentioned in pytorch/SpatialGridSamplerBilinear.c at f064c5aa33483061a48994608d890b968ae53fb5 · pytorch/pytorch · GitHub