Fix data race on owns_pyobj_ accesses with non-GIL protected threads
Fixes https://github.com/pytorch/pytorch/issues/75529
Signed-off-by: Edward Z. Yang <ezyangfb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/75563
Approved by: https://github.com/swolchok