Fix the lifetime of PyTensorType (#51649)
Summary:
Make sure that `PyTensorType` objects are always available during the shutdown.
See https://github.com/pytorch/pytorch/issues/42125#issuecomment-772397319 for a more in-depth explanation of why it's needed.
Fixes https://github.com/pytorch/pytorch/issues/42125.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51649
Reviewed By: zhangguanheng66
Differential Revision: D26256843
Pulled By: ezyang
fbshipit-source-id: 4d1dac75e063f0bdc65e0784140641fc4beb8616