[SPMD] Make compile cache the compilation result and add option to perform transformation (#97836)
This PR changes ``compile()`` decorator to cache the compilation result so that the compilation is done once. An gm_transformation option is also added to ``compile()`` so that after the compilation is done, users can perform any graph transformation with the compiled graph module.
Differential Revision: [D44484033](https://our.internmc.facebook.com/intern/diff/D44484033/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97836
Approved by: https://github.com/mrshenli, https://github.com/wconstab