Add test case for issue: https://github.com/pytorch/pytorch/issues/77851 (#78547)
The test works fine now.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78547
Approved by: https://github.com/kulinseth
(cherry picked from commit aa62b3e003b53a0b36e04005fe5fdc8e2dda0253)