code: def test_speed(self):
      import time
  
      def dynamic_quantize_pt2e(model, example_inputs):
          torch._dynamo.reset()
          model = capture_pre_autograd_graph(model, example_inputs)
          # Per channel quantization for weight
          # Dynamic quantization for activation
          # Please read a detail: https://fburl.com/code/30zds51q
          embedding_quantizer = EmbeddingQuantizer()
          dynamic_quantizer = XNNPACKQuantizer()
          operator_config_dynamic = get_symmetric_quantization_config(
              is_per_channel=True, is_dynamic=True
          )
          dynamic_quantizer.set_global(operator_config_dynamic)
          composed_quantizer = ComposableQuantizer(
              [embedding_quantizer, dynamic_quantizer]
          )
          prev = time.time()
          model = prepare_qat_pt2e(model, composed_quantizer)
          cur = time.time()
          # print("prepare time:", cur - prev)
          # Without Calibraiton, scale/zero value will have an initialized value of 1.0
          # Per channel quantization needs a proper scale/zero shape/value to work properly.
          # So we need to run calibration before converting to quantized model.
          model(*example_inputs)
          prev = time.time()
          model = convert_pt2e(model)
          cur = time.time()
          # uncomment to see the time
          # print("convert time:", cur - prev)
          return model
  
      class M(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.linear = torch.nn.Linear(5, 5)
  
          def forward(self, x):
              return self.linear(x)
  
      m = M().eval()
      example_inputs = (torch.randn(5, 5),)
      _ = dynamic_quantize_pt2e(m, example_inputs)
  
imports: from typing import List, Tuple
  import torch
  from torch._export import capture_pre_autograd_graph
  from torch import Tensor
  from torch.ao.quantization import observer, ObserverOrFakeQuantize, QConfigMapping
  from torch.ao.quantization.quantizer import DerivedQuantizationSpec, FixedQParamsQuantizationSpec, QuantizationAnnotation, QuantizationSpec, Quantizer, SharedQuantizationSpec
  from torch.ao.quantization.quantizer.xnnpack_quantizer import XNNPACKQuantizer, get_symmetric_quantization_config
  from torch.ao.quantization.quantizer.xnnpack_quantizer_utils import OP_TO_ANNOTATOR, QuantizationConfig
  from torch.ao.quantization.quantizer.composable_quantizer import ComposableQuantizer
  from torch.ao.quantization.quantizer.embedding_quantizer import EmbeddingQuantizer
  from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e, prepare_qat_pt2e
  from torch.ao.quantization.qconfig import default_per_channel_symmetric_qnnpack_qconfig, float_qparams_weight_only_qconfig, per_channel_weight_observer_range_neg_127_to_127, QConfig, weight_observer_range_neg_127_to_127
  from torch.fx import Node
  from torch.testing._internal.common_quantization import NodeSpec, PT2EQuantizationTestCase, skipIfNoQNNPACK, TestHelperModules
  from torch.testing._internal.common_utils import TemporaryFileName
label_desc: Use image node_id 31 for calling the TestQuantizePT2E obj's underlying member method code with example usage: obj.test_speed() and returns: model, self