code: def prepare(
      model: GraphModule,
      node_name_to_scope: Dict[str, Tuple[str, type]],
      is_qat: bool,
  ) -> GraphModule:
      # Since we are mutating the graph as we go, we iterate over the original
      # nodes before observer insertion, instead of model.graph.nodes.
      nodes_before_observation = list(model.graph.nodes)
  
      # At the high level we construct a map from EdgeOrNode to a observer_or_fake_quant instance
      # all edge/nodes that belongs to the same group will use the same instance
      # and when we insert observers we'll just query this map to get the correct observer_or_fake_quant
      # instance
      edge_or_node_to_qspec = _get_edge_or_node_to_qspec(model)
      edge_or_node_to_group_id = _get_edge_or_node_to_group_id(
          edge_or_node_to_qspec
      )
      obs_or_fq_map = _get_obs_or_fq_map(
          edge_or_node_to_group_id, edge_or_node_to_qspec, is_qat
      )
  
      for node in nodes_before_observation:
          # TODO: simplify logic for inserting observers
          _maybe_insert_input_and_output_observers_for_node(
              node, model, obs_or_fq_map, is_qat
          )
  
      model = GraphModule(model, model.graph)
  
      _save_state(
          model,
          {},  # node_name_to_qconfig
          node_name_to_scope,
          PrepareCustomConfig(),
          {},  # equalization_node_name_to_qconfig
          QConfigMapping(),
          is_qat,
          set(),  # observed_node_names
      )
      return model
  
imports: import torch
  from torch._subclasses import FakeTensor
  from torch.ao.quantization.fx.prepare import _insert_obs_or_fq, _save_state, _is_activation_post_process_node, _create_obs_or_fq_from_qspec
  from torch.fx import GraphModule, Graph, Node
  from torch.fx.node import Argument
  from torch.ao.quantization import QConfigMapping
  from torch.ao.quantization.qconfig import QConfigAny
  from torch.ao.quantization.fx.custom_config import PrepareCustomConfig
  from typing import Dict, Tuple, Union, Any, Optional
  from torch.ao.quantization.quantizer import EdgeOrNode, SharedQuantizationSpec, QuantizationSpecBase
  from torch.ao.quantization import ObserverOrFakeQuantize
label_desc: Use image node_id 15 for calling a global function with example usage: prepare(model, node_name_to_scope, is_qat) and returns: model