class_docstr: An Interpreter executes an FX graph Node-by-Node. This pattern
  can be useful for many things, including writing code
  transformations as well as analysis passes.
  
  Methods in the Interpreter class can be overridden to customize
  the behavior of execution. The map of overrideable methods
  in terms of call hierarchy::
  
      run()
          +-- run_node
              +-- placeholder()
              +-- get_attr()
              +-- call_function()
              +-- call_method()
              +-- call_module()
              +-- output()
  
  Example:
  
      Suppose we want to swap all instances of ``torch.neg`` with
      ``torch.sigmoid`` and vice versa (including their ``Tensor``
      method equivalents). We could subclass Interpreter like so::
  
          class NegSigmSwapInterpreter(Interpreter):
              def call_function(self, target : Target,
                                args : Tuple, kwargs : Dict) -> Any:
                  if target == torch.sigmoid:
                      return torch.neg(*args, **kwargs)
                  return super().call_function(n)
  
              def call_method(self, target : Target,
                              args : Tuple, kwargs : Dict) -> Any:
                  if target == 'neg':
                      call_self, *args_tail = args
                      return call_self.sigmoid(*args_tail, **kwargs)
                  return super().call_method(n)
  
          def fn(x):
              return torch.sigmoid(x).neg()
  
          gm = torch.fx.symbolic_trace(fn)
          input = torch.randn(3, 4)
          result = NegSigmSwapInterpreter(gm).run(input)
          torch.testing.assert_close(result, torch.neg(input).sigmoid())
  
  Args:
      module (torch.nn.Module): The module to be executed
      garbage_collect_values (bool): Whether to delete values after their last
          use within the Module's execution. This ensures optimal memory usage during
          execution. This can be disabled to, for example, examine all of the intermediate
          values in the execution by looking at the ``Interpreter.env`` attribute.
      graph (Optional[Graph]): If passed, the interpreter will execute this
          graph instead of `module.graph`, using the provided `module`
          argument to satisfy any requests for state.
class_docstr_tok: ["An","Interpreter","executes","an","FX","graph","Node-by-Node",".","This","pattern","can","be","useful","for","many","things",",","including","writing","code","transformations","as","well","as","analysis","passes",".","Methods","in","the","Interpreter","class","can","be","overridden","to","customize","the","behavior","of","execution",".","The","map","of","overrideable","methods","in","terms","of","call","hierarchy",":",":","run","(",")","+","--","run_node","+","--","placeholder","(",")","+","--","get_attr","(",")","+","--","call_function","(",")","+","--","call_method","(",")","+","--","call_module","(",")","+","--","output","(",")","Example",":","Suppose","we","want","to","swap","all","instances","of","``","torch.neg","``","with","``","torch.sigmoid","``","and","vice","versa","(","including","their","``","Tensor","``","method","equivalents",")",".","We","could","subclass","Interpreter","like","so",":",":","class","NegSigmSwapInterpreter","(","Interpreter",")",":","def","call_function","(","self",",","target",":","Target",",","args",":","Tuple",",","kwargs",":","Dict",")","-",">","Any",":","if","target","==","torch.sigmoid",":","return","torch.neg","(","*","args",",","*","*","kwargs",")","return","super","(",")",".call_function","(","n",")","def","call_method","(","self",",","target",":","Target",",","args",":","Tuple",",","kwargs",":","Dict",")","-",">","Any",":","if","target","==","'neg","'",":","call_self",",","*","args_tail","=","args","return","call_self.sigmoid","(","*","args_tail",",","*","*","kwargs",")","return","super","(",")",".call_method","(","n",")","def","fn","(","x",")",":","return","torch.sigmoid","(","x",")",".neg","(",")","gm","=","torch.fx.symbolic_trace","(","fn",")","input","=","torch.randn","(","3",",","4",")","result","=","NegSigmSwapInterpreter","(","gm",")",".run","(","input",")","torch.testing.assert_close","(","result",",","torch.neg","(","input",")",".sigmoid","(",")",")","Args",":","module","(","torch.nn.Module",")",":","The","module","to","be","executed","garbage_collect_values","(","bool",")",":","Whether","to","delete","values","after","their","last","use","within","the","Module","'s","execution",".","This","ensures","optimal","memory","usage","during","execution",".","This","can","be","disabled","to",",","for","example",",","examine","all","of","the","intermediate","values","in","the","execution","by","looking","at","the","``","Interpreter.env","``","attribute",".","graph","(","Optional","[","Graph","]",")",":","If","passed",",","the","interpreter","will","execute","this","graph","instead","of","`","module.graph","`",",","using","the","provided","`","module","`","argument","to","satisfy","any","requests","for","state","."]
docstr: Run `module` via interpretation and return the result.
  
  Args:
      *args: The arguments to the Module to run, in positional order
      initial_env (Optional[Dict[Node, Any]]): An optional starting environment for execution.
          This is a dict mapping `Node` to any value. This can be used, for example, to
          pre-populate results for certain `Nodes` so as to do only partial evaluation within
          the interpreter.
      enable_io_processing (bool): If true, we process the inputs and outputs with graph's process_inputs and
          process_outputs function first before using them.
  
  Returns:
      Any: The value returned from executing the Module
docstr_tok: ["Run","`","module","`","via","interpretation","and","return","the","result",".","Args",":","*","args",":","The","arguments","to","the","Module","to","run",",","in","positional","order","initial_env","(","Optional","[","Dict","[","Node",",","Any","]","]",")",":","An","optional","starting","environment","for","execution",".","This","is","a","dict","mapping","`","Node","`","to","any","value",".","This","can","be","used",",","for","example",",","to","pre-populate","results","for","certain","`","Nodes","`","so","as","to","do","only","partial","evaluation","within","the","interpreter",".","enable_io_processing","(","bool",")",":","If","true",",","we","process","the","inputs","and","outputs","with","graph","'s","process_inputs","and","process_outputs","function","first","before","using","them",".","Returns",":","Any",":","The","value","returned","from","executing","the","Module"]
code: def run(
      self,
      *args,
      initial_env: Optional[Dict[Node, Any]] = None,
      enable_io_processing: bool = True,
  ) -> Any:
      """
      Run `module` via interpretation and return the result.
  
      Args:
          *args: The arguments to the Module to run, in positional order
          initial_env (Optional[Dict[Node, Any]]): An optional starting environment for execution.
              This is a dict mapping `Node` to any value. This can be used, for example, to
              pre-populate results for certain `Nodes` so as to do only partial evaluation within
              the interpreter.
          enable_io_processing (bool): If true, we process the inputs and outputs with graph's process_inputs and
              process_outputs function first before using them.
  
      Returns:
          Any: The value returned from executing the Module
      """
      self.env = initial_env if initial_env is not None else {}
  
      # Positional function args are consumed left-to-right by
      # `placeholder` nodes. Use an iterator to keep track of
      # position and extract those values.
      if enable_io_processing:
          args = self.graph.process_inputs(*args)
      self.args_iter: Iterator[Any] = iter(args)
      pbar = tqdm(
          total=len(self.graph.nodes),
          desc=f"{self.name}: {str(list(self.graph.nodes)) if config.verbose_progress else ''}",
          initial=0,
          position=0,
          leave=True,
          disable=config.disable_progress,
          delay=0,
      )
  
      for node in self.graph.nodes:
          pbar.update(1)
          if node in self.env:
              # Short circuit if we have this value. This could
              # be used, for example, for partial evaluation
              # where the caller has pre-populated `env` with
              # values for a subset of the program.
              continue
  
          try:
              self.env[node] = self.run_node(node)
          except Exception as e:
              if self.extra_traceback:
                  msg = f"While executing {node.format_node()}"
                  msg = f"{e.args[0]}\n\n{msg}" if e.args else str(msg)
                  msg += f"\nOriginal traceback:\n{node.stack_trace}"
                  e.args = (msg,) + e.args[1:]
                  if isinstance(e, KeyError):
                      raise RuntimeError(*e.args) from e
              raise
  
          if self.garbage_collect_values:
              for to_delete in self.user_to_last_uses.get(node, []):
                  del self.env[to_delete]
  
          if node.op == "output":
              output_val = self.env[node]
              return (
                  self.graph.process_outputs(output_val)
                  if enable_io_processing
                  else output_val
              )
  
imports: from .graph_module import GraphModule
  from .graph import Graph
  from .node import Argument, Node, Target, map_arg, map_aggregate
  from .proxy import Proxy
  from ._symbolic_trace import Tracer
  from ._compatibility import compatibility
  from .None import config
  import torch.fx.traceback
  import torch
  from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
  import inspect
  from contextlib import contextmanager
  from torch.hub import tqdm
label_desc: Use image node_id 2 for calling the Interpreter obj's underlying member method code with example usage: obj.run() and returns: unknown