code: def collect_producer_nodes(node: Node) -> Optional[List[Node]]:
      r"""Starting from a target node, trace back until we hit inpu or
      getattr node. This is used to extract the chain of operators
      starting from getattr to the target node, for example
      def forward(self, x):
        observed = self.observer(self.weight)
        return F.linear(x, observed)
      collect_producer_nodes(observed) will either return a list of nodes that
      produces the observed node or None if we can't extract a self contained
      graph without free variables(inputs of the forward function).
      """
      nodes = [node]
      frontier = [node]
      while frontier:
          node = frontier.pop()
          all_args = list(node.args) + list(node.kwargs.values())
          for arg in all_args:
              if not isinstance(arg, Node):
                  continue
              if arg.op == "placeholder":
                  # hit input, can't fold in this case
                  return None
              nodes.append(arg)
              if not (
                  arg.op == "call_function" and arg.target == getattr
              ):
                  frontier.append(arg)
      return nodes
  
imports: import copy
  import torch
  import torch.nn
  from torch.ao.quantization import QConfigAny, QuantType
  from torch.ao.quantization.backend_config import DTypeWithConstraints
  from torch.ao.quantization.fake_quantize import FakeQuantizeBase, FixedQParamsFakeQuantize
  from torch.ao.quantization.observer import FixedQParamsObserver, ObserverBase
  from torch.ao.quantization.qconfig import float16_static_qconfig, float16_dynamic_qconfig, qconfig_equals
  from torch.ao.quantization.stubs import DeQuantStub
  from torch.ao.quantization.utils import activation_is_statically_quantized
  from torch.ao.quantization.observer import _is_activation_post_process
  from torch.ao.quantization.qconfig_mapping import QConfigMapping
  from torch.fx import GraphModule, map_arg
  from torch.fx.graph import Graph, Node
  from .custom_config import PrepareCustomConfig
  from ._decomposed import quantized_decomposed_lib
  from typing import Callable, Optional, List, Dict, Any, Set, Tuple, Union, Type
  from dataclasses import dataclass
  from collections import namedtuple
  import operator
  import warnings
label_desc: Use image node_id 7 for calling a global function with example usage: collect_producer_nodes(node) and returns: nodes, None