Use the new `get_unique_name_wrt` helper when applicable (#146950)
Summary:
This patch removes some duplicated name generation logic in Dynamo.
X-link: https://github.com/pytorch/pytorch/pull/146950
Approved by: https://github.com/zou3519
ghstack dependencies: #146714, #146367
Reviewed By: wdvr
Differential Revision: D70270821
fbshipit-source-id: cc8a04342adb2056f19709007ef45e3ad6ee34f8