[FX] Refactor unique name handling (#48205)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/48205
Test Plan: Imported from OSS
Reviewed By: zdevito
Differential Revision: D25068934
Pulled By: jamesr66a
fbshipit-source-id: 04e02bbfd2cc9a8c3b963d9afdf40bac065c319b