[PyTorch][easy] Don't call IValue::type twice in Pickler::endTypeTag (#96214)
The duplicate call is unlikely to be eliminated by the compiler (it can return a new heap-allocated object).
Differential Revision: [D43877846](https://our.internmc.facebook.com/intern/diff/D43877846/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/96214
Approved by: https://github.com/zhxchen17