code: def _check_against_ref_dynamic_ptq(self, model):
      model.eval()
      inputs = model.get_example_inputs()
      ref_m = torch.jit.script(model)
      torch._C._jit_pass_inline(ref_m.graph)
      qconfig_dict = {"": default_dynamic_qconfig}
      ref_m = prepare_dynamic_jit(ref_m, qconfig_dict)
      ref_m = convert_dynamic_jit(ref_m)
      ref_output = ref_m(*inputs)
  
      m = OnDevicePTQUtils.ptq_dynamic_quantize(model, qconfig_dict)
      m.observe_forward(*inputs)
      m.quantize_forward(*inputs)
      output = m.quantized_forward(*inputs)
      self.assertTrue(torch.allclose(ref_output, output))
      thrown = False
      try:
          m(*inputs)
      except Exception as e:
          thrown = True
      self.assertTrue(thrown)
  
      # test with per channel quant
      ref_m = torch.jit.script(model)
      torch._C._jit_pass_inline(ref_m.graph)
      qconfig_dict = {"": per_channel_dynamic_qconfig}
      ref_m = prepare_dynamic_jit(ref_m, qconfig_dict)
      ref_m = convert_dynamic_jit(ref_m)
      ref_output = ref_m(*inputs)
  
      m = OnDevicePTQUtils.ptq_dynamic_quantize(model, qconfig_dict)
      m.observe_forward(*inputs)
      m.quantize_forward(*inputs)
      output = m.quantized_forward(*inputs)
      self.assertTrue(torch.allclose(ref_output, output))
      thrown = False
      try:
          m(*inputs)
      except Exception as e:
          thrown = True
      self.assertTrue(thrown)
  
imports: import torch
  import torch._C
  from torch.ao.quantization import default_dynamic_qconfig, per_channel_dynamic_qconfig
  from torch.ao.quantization.quantize_jit import prepare_dynamic_jit, convert_dynamic_jit, _prepare_ondevice_dynamic_jit, _quantize_ondevice_dynamic_jit
  from torch.testing._internal.common_utils import TestCase
  from torch.testing._internal.common_quantization import get_script_module, LinearAddModel
  from torch.jit.mobile import _load_for_lite_interpreter, LiteScriptModule
  from torch.testing import FileCheck
  from torch.utils import bundled_inputs
  import io
  from typing import Dict
label_desc: Use image node_id 7 for calling the TestOnDeviceDynamicPTQFinalize obj's underlying member method code with example usage: obj._check_against_ref_dynamic_ptq(model) without return types