Use the same checks in all `grid_sampler` functions (#74635)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/74635
Fixes #73187.
Test Plan: Imported from OSS
Reviewed By: bdhirsh
Differential Revision: D35284563
Pulled By: albanD
fbshipit-source-id: 1477c506b8755d864ca902ee140bee7bdb0069b0
(cherry picked from commit dcbd5242baaae11f9e323d99a9596e5b88e86bd7)