[SPMD] Allow IterGraph support a more general subgraph movement (#98360)
Resubmit D44444398 due to the merging conflict.
The original assumption of IterGraph is very restrictive and only allow users to move a subgraph that only one node has the input from external nodes. This PR fixes the limitation.
Differential Revision: [D44689730](https://our.internmc.facebook.com/intern/diff/D44689730/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D44689730/)!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98360
Approved by: https://github.com/lessw2020