[Profiler] Compute unique IDs for Tensors (#85162)
This PR is largely based on https://github.com/pytorch/pytorch/pull/80266, with one major difference. #80266 assigned each unique {TensorImpl, StorageImpl} pair a unique ID, whereas this PR seeks to cluster the implicit graph formed by the pairs into disjoint groups and assign an ID to each disjoint group.
Differential Revision: [D39563859](https://our.internmc.facebook.com/intern/diff/D39563859/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85162
Approved by: https://github.com/chaekit