[PyTorch] Reduce refcount bumps in ClassType (#66724)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66724
Forwarding fix from previous diff through the ClassType getters & moving Types in where possible.
ghstack-source-id: 141594741
Test Plan: CI
Reviewed By: suo
Differential Revision: D31697995
fbshipit-source-id: 05d6af7c23e3b7a94db75b20d06338bc9ade3e20