class_docstr: Generates a FX GraphModule using torch.dynamo.export API
  Args:
      aten_graph: If True, exports a graph with ATen operators.
                  If False, exports a graph with Python operators.
class_docstr_tok: ["Generates","a","FX","GraphModule","using","torch.dynamo.export","API","Args",":","aten_graph",":","If","True",",","exports","a","graph","with","ATen","operators",".","If","False",",","exports","a","graph","with","Python","operators","."]
code: def generate_fx(
      self,
      options: exporter.ResolvedExportOptions,
      model: Union[torch.nn.Module, Callable],
      model_args: Sequence[Any],
      model_kwargs: Mapping[str, Any],
  ) -> torch.fx.GraphModule:
      # `dynamo.export` does not recognize custom user defined classes as output type.
      # Apply wrapper to adapt the outputs back to `dynamo.export` compatible types,
      # i.e. :class:`torch.Tensor`.
      dynamo_flatten_output_step = DynamoFlattenOutputStep()
      wrapped_model = _wrap_model_with_output_adapter(
          model, dynamo_flatten_output_step
      )
      # Record the output adapter step.
      self.output_adapter.append_step(dynamo_flatten_output_step)
  
      # Translate callable to FX graph.
      #
      fake_mode = (
          options.fake_context.fake_mode
          if options.fake_context
          else contextlib.nullcontext()
      )
      fx_mode = "symbolic" if options.dynamic_shapes else "fake"
      with fake_mode:  # type: ignore[attr-defined]
          graph_module, graph_guard = torch._dynamo.export(
              wrapped_model,
              tracing_mode=fx_mode,
          )(
              *model_args,
              **model_kwargs,
          )
      del graph_guard  # Unused
      torch._dynamo.reset()
  
      # Export FX graph to ONNX ModelProto.
      self.input_adapter.append_step(
          io_adapter.FlattenInputWithTreeSpecValidationInputStep()
      )
  
      updated_model_args = self.input_adapter.apply(
          *model_args, model=model, **model_kwargs
      )
  
      return self.pre_export_passes(
          options, model, graph_module, updated_model_args
      )
  
imports: from __future__ import annotations
  import contextlib
  import functools
  import inspect
  from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union
  import torch._dynamo
  import torch.export
  import torch.fx
  import torch.onnx
  from torch.onnx._internal import _beartype, exporter, io_adapter
  from torch.utils import _pytree
label_desc: Use image node_id 2 for calling the DynamoExport obj's underlying member method code with example usage: obj.generate_fx(options, model, model_args, model_kwargs) and returns: self