[fix] fix test_python_dispatch with pytest (#64574)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/62501
Another approach for fixing the same issue
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64574
Reviewed By: ngimel
Differential Revision: D30867237
Pulled By: ezyang
fbshipit-source-id: c632a1e0b241effdc21ae929abe42fccec88aa24