class_docstr: A backend compiles (sub-)graphs in torch.fx.GraphModule to onnxruntime.InferenceSession calls.
  
  The compiler entry point is OrtBackend.compile, which
      1. partitions the original graph into supported sub-graphs (type: torch.fx.GraphModule) and unsupported
         sub-graphs.
      2. For each supported sub-graph, it replaces its _wrapped_call function with _ort_accelerated_call.
      3. Inside _ort_accelerated_call, it creates onnxruntime.InferenceSession and calls it to execute the sub-graph.
class_docstr_tok: ["A","backend","compiles","(","sub-",")","graphs","in","torch.fx.GraphModule","to","onnxruntime.InferenceSession","calls",".","The","compiler","entry","point","is","OrtBackend.compile",",","which","1.","partitions","the","original","graph","into","supported","sub-graphs","(","type",":","torch.fx.GraphModule",")","and","unsupported","sub-graphs",".","2",".","For","each","supported","sub-graph",",","it","replaces","its","_wrapped_call","function","with","_ort_accelerated_call",".","3",".","Inside","_ort_accelerated_call",",","it","creates","onnxruntime.InferenceSession","and","calls","it","to","execute","the","sub-graph","."]
code: def __init__(self, options: Optional[OrtBackendOptions] = None):
      self._options: Final = (
          OrtBackendOptions() if options is None else options
      )
  
      # options.export_options contains information shared between exporter and DORT.
      # For example, they should use the same decomposition table when
      #  1. capturing FX graph in torch.compile (see how we create aot_ort in register_backend.py)
      #  2. call exporter's API to convert `torch.fx.GraphModule` to ONNX model
      #     (see onnxfunction_dispatcher passed to FxOnnxInterpreter.run below).
      #
      # Convert user-facing option to internal option used by ONNX exporter
      # to access required information.
      # Some useful fields:
      # - Decomposition table for decomposing FX operators in exporter is
      #   self._resolved_onnx_exporter_options.decomposition_table.
      # - self._resolved_onnx_exporter_options.onnx_registry records what
      #   aten/prim ops are supported by exporter and their exporters (type: callable).
      self._resolved_onnx_exporter_options = (
          torch.onnx._internal.exporter.ResolvedExportOptions(
              torch.onnx.ExportOptions()
              if self._options.export_options is None
              else self._options.export_options
          )
      )
  
      #  Given DORT's computation flow:
      #   1. OrtOperatorSupport uses support_dict and extra_support_dict to select operators
      #      and send them to DORT.
      #   2. Then, DORT exports the selected sub-graphs into ONNX.
      #   3. Finally DORT calls ORT to do the computation.
      #  OrtOperatorSupport and create_onnx_friendly_decomposition_table(...)
      #  must use the same support_dict. If the support_dict here contains something not
      #  supported by exporter, exporter will fails in step 2 since the selected graphs may
      #  contains unsupported operators such as aten::_who_you_are.
      #  This restriction is automatically done since DORT and exporter shares the same
      #  self._resolved_onnx_exporter_options.
      support_dict = torch.onnx._internal.fx.decomposition_table._create_onnx_supports_op_overload_table(
          self._resolved_onnx_exporter_options.onnx_registry
      )
  
      extra_support_dict: Dict[str, Any] = {
          "getattr": None,
          # To send operator.getitem to ORT, add the corresponding string
          # recognized by PyTorch's OperatorSupport class.
          "_operator.getitem": None,
          # To send operator.mul to ORT, add the corresponding string
          # recognized by PyTorch's OperatorSupport class.
          "_operator.mul": None,
          "_operator.add": None,
          "_operator.sub": None,
      }
  
      self._supported_ops = OrtOperatorSupport(
          support_dict, extra_support_dict
      )
      # TODO(wschin): this is a naive implementation of cache without proper guard
      # See https://github.com/pytorch/pytorch/issues/106868.
      self._partitioner_cache: Dict[
          torch.fx.GraphModule, torch.fx.GraphModule
      ] = {}
      # Conceptually, this filed is a 2-layer dictionary
      #   GraphModule 0
      #     ONNX Model 0 (with ORT InferenceSession and related information. type: OrtExecutionInfoPerSession)
      #     ONNX Model 1
      #     ...
      #   GraphModule 1
      #     ONNX Model 2 (with ORT InferenceSession and related information. type: OrtExecutionInfoPerSession)
      #     ONNX Model 3
      #     ...
      #   ...
      # , which caches all previous compilation result so that we can reuse them.
      # ONNX Model 0 and 1 are exported from the same GraphModule 0 but with different inputs
      # (e.g., tensors with different ranks). GraphModule 0 and GraphModule 1 are different
      # graphs captured by Dynamo and sent to OrtBackend.compile.
      self._all_ort_execution_info = (
          OrtExecutionInfoForAllGraphModules()
      )
  
      self._assert_allclose_to_baseline = False
  
      self.execution_count = 0
  
      # Function which invokes ORT do to the real computation.
      self.run = (
          _run_onnx_session_with_ortvaluevector
          if hasattr(ORTC.OrtValueVector, "push_back_batch")
          else _run_onnx_session_with_fetch
      )
  
imports: import dataclasses
  import importlib
  import logging
  from typing import Any, Dict, Final, List, Mapping, Optional, Sequence, Set, Tuple, Union
  from typing_extensions import TypeAlias
  import torch
  import torch._C
  import torch._ops
  import torch._prims.executor
  import torch.fx
  from torch._subclasses.fake_tensor import FakeTensor
  from torch.fx._compatibility import compatibility
  from torch.fx.passes.fake_tensor_prop import FakeTensorProp
  from torch.fx.passes.operator_support import OperatorSupport
  from torch.fx.passes.tools_common import CALLABLE_NODE_OPS
  from torch.utils import _pytree
label_desc: Use image node_id 1 to create a new OrtBackend object  with example: obj = OrtBackend(options)