Move graph iterator to seperate utility file (#56211)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56211
Test Plan: Imported from OSS
Reviewed By: gmagogsfm
Differential Revision: D27828150
Pulled By: tugsbayasgalan
fbshipit-source-id: f91747fabde9caf864a62e4028fdc7bbbab7ee66