code: def _get_obs_or_fq_map(
      edge_or_node_to_group_id: Dict[EdgeOrNode, int],
      edge_or_node_to_qspec: Dict[EdgeOrNode, QuantizationSpecBase],
      is_qat: bool,
  ) -> Dict[EdgeOrNode, ObserverOrFakeQuantize]:
      """Generates the EdgeOrNode to observer/fake_quant instances
      Makes sure that for EdgeOrNode that has the same group_id should have the same observer or fake quant
      instances
      """
      obs_or_fq_map: Dict[EdgeOrNode, ObserverOrFakeQuantize] = {}
      group_id_to_obs_or_fq: Dict[int, ObserverOrFakeQuantize] = {}
      for edge_or_node, qspec in edge_or_node_to_qspec.items():
          group_id = edge_or_node_to_group_id[edge_or_node]
          if group_id not in group_id_to_obs_or_fq:
              # TODO: maybe edge_or_node_to_qspec should be edge_or_node_to_root_qspec, this will simplify
              # the implementation for _create_obs_or_fq_from_qspec
              group_id_to_obs_or_fq[
                  group_id
              ] = _create_obs_or_fq_from_qspec(
                  qspec, obs_or_fq_map, is_qat
              )
          obs_or_fq_map[edge_or_node] = group_id_to_obs_or_fq[group_id]
      return obs_or_fq_map
  
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 10 for calling a global function with example usage: _get_obs_or_fq_map(edge_or_node_to_group_id, edge_or_node_to_qspec, is_qat) and returns: obs_or_fq_map