class_docstr: Provides information about an exported module.
  For a particular fx GraphModule, this class contains information on:
  (1) Which graph inputs are parameters, buffers, or user inputs
  (2) (for params/buffers) a mapping from the name of each graph argument
      to its parameter/buffer FQN in the original nn.Module.
  (3) If there are input mutations, these are represented as extra outputs
      in the fx GraphModule. We provide a mapping from these
      extra output names to the names of the actual inputs.
  (4) The pytree metadata on how to flatten/unflatten inputs and outputs.
      The corresponding FX GraphModule only accepts and returns
      pytree-flattened inputs/outputs.
  (5) (Optionally) if the FX is a joint forward-backward graph, we provide
      a signature on the backward section of the joint graph.
class_docstr_tok: ["Provides","information","about","an","exported","module",".","For","a","particular","fx","GraphModule",",","this","class","contains","information","on",":","(","1",")","Which","graph","inputs","are","parameters",",","buffers",",","or","user","inputs","(","2",")","(","for","params\/buffers",")","a","mapping","from","the","name","of","each","graph","argument","to","its","parameter\/buffer","FQN","in","the","original","nn.Module",".","(","3",")","If","there","are","input","mutations",",","these","are","represented","as","extra","outputs","in","the","fx","GraphModule",".","We","provide","a","mapping","from","these","extra","output","names","to","the","names","of","the","actual","inputs",".","(","4",")","The","pytree","metadata","on","how","to","flatten\/unflatten","inputs","and","outputs",".","The","corresponding","FX","GraphModule","only","accepts","and","returns","pytree-flattened","inputs\/outputs",".","(","5",")","(","Optionally",")","if","the","FX","is","a","joint","forward-backward","graph",",","we","provide","a","signature","on","the","backward","section","of","the","joint","graph","."]
code: def from_tracing_metadata(
      cls,
      *,
      in_spec: pytree.TreeSpec,
      out_spec: pytree.TreeSpec,
      graph_input_names: List[str],
      graph_output_names: List[str],
      view_mutation_metadata: ViewAndMutationMeta,
      named_parameters: List[str],
      named_buffers: List[str],
      num_user_inputs: int,
      num_user_outputs: int,
      loss_index: Optional[int],
      backward_signature: Optional[BackwardSignature],
  ) -> "GraphSignature":
      graph_inputs = graph_input_names
      graph_outputs = graph_output_names
      parameters = list(named_parameters)
      buffers = list(named_buffers)
  
      # Calling convention assumptions:
      # (1) graph inputs = (params, buffers, user_inputs)
      # (2) graph outputs = (mutated_inputs, user_outs, param_gradients)
      # (If we are capturing an inference graph, this convention is identical
      #  except that param_gradients is empty)
      user_inputs = graph_inputs[len(parameters) + len(buffers) :]
      assert num_user_inputs == len(user_inputs)
      assert len(graph_inputs) == (
          len(parameters) + len(buffers) + len(user_inputs)
      )
  
      inputs_to_parameters = dict(
          zip(graph_inputs[: len(parameters)], parameters)
      )
      inputs_to_buffers = dict(
          zip(
              graph_inputs[
                  len(parameters) : len(parameters) + len(buffers)
              ],
              buffers,
          )
      )
  
      state_names = [*parameters, *buffers]
      mutated_buffers = []
      for idx, input_info in enumerate(
          view_mutation_metadata.input_info
      ):
          if input_info.mutates_data:
              # Only buffers can be mutated, not parameters
              assert idx >= len(parameters)
              buffer_name = state_names[idx]
              mutated_buffers.append(buffer_name)
  
      assert (
          len(mutated_buffers)
          == view_mutation_metadata.num_mutated_inp_runtime_indices
      )
  
      start, stop = (
          0,
          view_mutation_metadata.num_mutated_inp_runtime_indices,
      )
      buffers_to_mutate = dict(
          zip(graph_outputs[start:stop], mutated_buffers)
      )
  
      start, stop = stop, stop + num_user_outputs
      user_outputs = graph_outputs[start:stop]
  
      unused_outputs = len(graph_outputs) - stop
      if backward_signature is not None:
          unused_outputs -= len(
              backward_signature.gradients_to_parameters
          ) + len(backward_signature.gradients_to_user_inputs)
      assert unused_outputs == 0
  
      return GraphSignature(
          parameters=parameters,  # type: ignore[arg-type]
          buffers=buffers,  # type: ignore[arg-type]
          user_inputs=user_inputs,  # type: ignore[arg-type]
          user_outputs=user_outputs,  # type: ignore[arg-type]
          inputs_to_buffers=inputs_to_buffers,  # type: ignore[arg-type]
          inputs_to_parameters=inputs_to_parameters,  # type: ignore[arg-type]
          buffers_to_mutate=buffers_to_mutate,  # type: ignore[arg-type]
          in_spec=in_spec,
          out_spec=out_spec,
          backward_signature=backward_signature,
      )
  
imports: import collections
  from dataclasses import dataclass
  from enum import Enum
  from typing import Any, Callable, Dict, List, NewType, Optional, Set, Tuple, Union
  import torch
  import torch.utils._pytree
  from torch._guards import Source
  from torch._subclasses import FakeTensor
  from torch._subclasses.fake_tensor import is_fake
  from ..None import config
  from .utils import strict_zip
label_desc: Use image node_id 1 for calling the GraphSignature obj's underlying member method code with example usage: obj.from_tracing_metadata(cls) and returns: GraphSignature