[PyTorch] Fix getCustomClassType() perf (#48981)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/48981
1) It was copying the entire hash table every time.
2) We don't need to do a hash lookup at all.
ghstack-source-id: 118164406
Reviewed By: dzhulgakov
Differential Revision: D25385543
fbshipit-source-id: 6be95c742d6713345c51859ce36a7791a9e2e3f0