[PyTorch][JIT] Return a reference from caching specializations of getTypePtr (#66342)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66342
`decltype(auto)` in D31486117 (https://github.com/pytorch/pytorch/commit/fb5a80ffd80997eabf724282e62a7eaf4a78c2ad) wasn't the right choice in these specializations, because it will *still* deduce a copy.
See https://godbolt.org/z/GjbcPE1c4 for example.
ghstack-source-id: 140144199
Test Plan: CI, added new static_assert to make sure we got it right for std::tuple in particular
Reviewed By: hlu1, JasonHanwen
Differential Revision: D31514960
fbshipit-source-id: cae722aa34345b590c46eae478229cb5f4b0d7dc