code: def _test_metadata_porting(
      self,
      model,
      example_inputs,
      quantizer,
      node_tags=None,
  ) -> torch.fx.GraphModule:
      m_eager = model.eval()
  
      # program capture
      m = copy.deepcopy(m_eager)
      m = export.capture_pre_autograd_graph(
          m,
          example_inputs,
      )
  
      m = prepare_pt2e(m, quantizer)
      # Calibrate
      m(*example_inputs)
      m = convert_pt2e(m, fold_quantize=True)
  
      pt2_quant_output = m(*example_inputs)
      recorded_node_tags = {}
      for n in m.graph.nodes:
          if "quantization_tag" not in n.meta:
              continue
          if n.op == "call_function" and n.target in _QUANT_OPS:
              key = n.target
          elif n.op == "get_attr":
              key = "get_attr"
          else:
              continue
  
          if key not in recorded_node_tags:
              recorded_node_tags[key] = set()
  
          if (
              n.op == "call_function"
              and n.meta["quantization_tag"] in recorded_node_tags[key]
          ):
              raise ValueError(
                  f"{key} {n.format_node()} has tag {n.meta['quantization_tag']} that "
                  "is associated with another node of the same type"
              )
          recorded_node_tags[key].add(n.meta["quantization_tag"])
  
      self.assertEqual(
          set(recorded_node_tags.keys()), set(node_tags.keys())
      )
      for k, v in recorded_node_tags.items():
          self.assertEqual(v, node_tags[k])
      return m
  
imports: import copy
  import unittest
  from typing import List
  import torch
  import torch._export
  from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
  from torch.ao.quantization.quantizer import Quantizer
  from torch.ao.quantization.quantizer.xnnpack_quantizer import get_symmetric_quantization_config
  from torch.ao.quantization.quantizer.xnnpack_quantizer_utils import OP_TO_ANNOTATOR
  from torch.fx import Node
  from torch.testing._internal.common_quantization import QuantizationTestCase
  from torch.testing._internal.common_utils import IS_WINDOWS
label_desc: Use image node_id 2 for calling the TestMetaDataPorting obj's underlying member method code with example usage: obj._test_metadata_porting(model, example_inputs, quantizer, node_tags) and returns: m