[export] avoid calling the callable during export. (#107249)
We avoid calling user's function f again in export. It's error prone (due to side effects in f) and time-consuming. Instead, we directly manipulate the out_spec of the graph module to make sure the graph module outputs a tuple so that aot_export is happy.
The out_spec of gm_torch_level is computed from dynamo traced result and is guaranteed to be the same output as eagerly running user's original callable f.
Test Plan:
existing tests.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/107249
Approved by: https://github.com/tugsbayasgalan