code: def _test_quantize_model(self, model_config):
      if get_torch_version() >= [1, 11]:
          import torch.ao.quantization as tq
          from torch.ao.quantization.quantize_fx import (
              convert_fx,
              prepare_fx,
          )
      else:
          import torch.quantization as tq
          from torch.quantization.quantize_fx import (
              convert_fx,
              prepare_fx,
          )
  
      # quantize model
      model = build_model(model_config)
      model.eval()
  
      input = torch.ones([1, 3, 32, 32])
  
      heads = model.get_heads()
      # since prepare changes the code of ClassyBlock we need to clear head first
      # and reattach it later to avoid caching
      model.clear_heads()
  
      prepare_custom_config_dict = {}
      head_path_from_blocks = [
          _find_block_full_path(model.features, block_name)
          for block_name in heads.keys()
      ]
      fqn_to_example_inputs = None
      if get_torch_version() >= [1, 13]:
          from torch.ao.quantization.utils import (
              get_fqn_to_example_inputs,
          )
  
          fqn_to_example_inputs = get_fqn_to_example_inputs(
              model, (input,)
          )
  
      standalone_example_inputs = (torch.randn(1, 3, 3, 3),)
      # we need to keep the modules used in head standalone since
      # it will be accessed with path name directly in execution
      if get_torch_version() >= [1, 13]:
          prepare_custom_config_dict["standalone_module_name"] = [
              (
                  head,
                  {"": tq.default_qconfig},
                  fqn_to_example_inputs["features." + head],
                  {
                      "input_quantized_idxs": [0],
                      "output_quantized_idxs": [],
                  },
                  None,
              )
              for head in head_path_from_blocks
          ]
      else:
          prepare_custom_config_dict["standalone_module_name"] = [
              (
                  head,
                  {"": tq.default_qconfig},
                  standalone_example_inputs,
                  {
                      "input_quantized_idxs": [0],
                      "output_quantized_idxs": [],
                  },
                  None,
              )
              for head in head_path_from_blocks
          ]
  
      example_inputs = (torch.randn(1, 3, 3, 3),)
      if get_torch_version() >= [1, 13]:
          example_inputs = fqn_to_example_inputs["initial_block"]
      model.initial_block = prepare_fx(
          model.initial_block, {"": tq.default_qconfig}, example_inputs
      )
  
      if get_torch_version() >= [1, 13]:
          example_inputs = fqn_to_example_inputs["features"]
      model.features = prepare_fx(
          model.features,
          {"": tq.default_qconfig},
          example_inputs,
          prepare_custom_config_dict,
      )
      model.set_heads(heads)
  
      # calibration
      model(input)
  
      heads = model.get_heads()
      model.clear_heads()
      model.initial_block = convert_fx(model.initial_block)
      model.features = convert_fx(model.features)
      model.set_heads(heads)
  
      output = model(input)
      self.assertEqual(output.size(), (1, 1000))
  
file_path: ClassyVision/test/models_densenet_test.py
imports: import unittest
  import torch
  from classy_vision.generic.util import get_torch_version
  from classy_vision.models import build_model
  from test.generic.utils import compare_model_state
label_desc: Use image node_id 2 for calling the TestDensenet obj's underlying member method code with example usage: obj._test_quantize_model(model_config) without return types