[SPMD] Allow users to dynamically pass the last_iter to IterGraphModule (#99575)
The current design of IterGraphModule requires users to specify the concrete iteration count which is not always possible and not very precise. This PR introduce `last_iter` to IterGraphModule.forward() which allows users to dynamically specify the last iteration.
Differential Revision: [D45129585](https://our.internmc.facebook.com/intern/diff/D45129585/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/99575
Approved by: https://github.com/lessw2020