Avoid race condition in intrusive_ptr.reset_() (#24464)
Summary:
This is a spin-off from https://github.com/pytorch/pytorch/issues/24368 (high priority inherited from https://github.com/pytorch/pytorch/issues/3818).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/24464
Differential Revision: D16928898
Pulled By: ezyang
fbshipit-source-id: 2d66c7adbd52de52869b1fe69ce2842d035dbf86