Refactor the fetching of subgraph names (#152770)
Summary:
X-link: https://github.com/pytorch/pytorch/pull/152770
Approved by: https://github.com/jansel, https://github.com/zou3519
ghstack dependencies: #152772
Reviewed By: huydhn
Differential Revision: D74226447
fbshipit-source-id: 57382bd4a35e54644c55d76f4f8489a8e3ffc73b