[export] Copy gm before calling PassManager (#108321)
Test Plan: CI
Reviewed By: angelayi, cccclai
Differential Revision: D48801487
Pull Request resolved: https://github.com/pytorch/pytorch/pull/108321
Approved by: https://github.com/kimishpatel, https://github.com/mcr229