Catch saved tensors default hooks race condition (#61957)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61957
If the user runs code that registers default saved tensor hooks from
multiple threads, it will fail with a nice error message most of the
time. This commit handles the very rare case where a race condition
would have made it fail silently.
Test Plan: Imported from OSS
Reviewed By: zou3519
Differential Revision: D29848525
Pulled By: Varal7
fbshipit-source-id: eb9bdcfbeed857a988834651246390ea14eedd33