[c10] fix weak_intrusive_ptr lock() (#46007)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46007
When owner released the object, target will become null and illegal to
access refcount_ again. This PR fixes this and return null in that case.
Test Plan: Imported from OSS
Reviewed By: gmagogsfm
Differential Revision: D24374846
Pulled By: wanchaol
fbshipit-source-id: 741074f59c0904a4d60b7bde956cad2d0925be4e