code: def check_quantize(
      net_original,
      data_shapes,
      out_type,
      name="conv",
      check_calibration=True,
      check_scale_align=False,
      quantize_mode="full",
      attrs_dict={},
      calib_mode="naive",
      check_fusion=True,
  ):
      quantize_granularity_list = ["tensor-wise"]
      if name == "fc":
          quantize_granularity_list += ["channel-wise"]
  
      if name in config:
          name = config[name][OP_NAME]
  
      sigma = (
          0.01
          if hasattr(net_original, "alg") is True
          and net_original.alg == "exp"
          else 0.5
      )
      if out_type == "uint8":
          # Initialize weights and tensors only with positive values to be sure
          # that results are always positive
          init = CustomNormalInit(sigma=sigma, bounded=True)
          min_value = 0
      else:
          init = mx.init.Normal(sigma)
          min_value = -1
  
      net_original.initialize(init=init, force_reinit=True)
  
      one_shape = isinstance(data_shapes, tuple)
      if one_shape:
          # replace one shape with list of shapes with one element inside to follow later the same schema
          data_shapes = [data_shapes]
      data = []
      for shape in data_shapes:
          data.append(
              mx.np.random.uniform(
                  min_value,
                  1.0,
                  size=shape,
                  dtype="float32",
                  device=mx.cpu(),
              )
          )
  
      outputs = net_original(*data)
      for output in outputs:
          output.wait_to_read()
      ref_out = outputs
      one_output = not isinstance(ref_out, list)
      if one_output:
          # make a list to have a common path for one and multiple outputs
          ref_out = [ref_out]
  
      class TestDataLoader(mx.gluon.data.DataLoader):
          def __init__(self, data):
              self.data = data
              self.finish = False
  
          def __iter__(self):
              self.finish = False
              return self
  
          def __next__(self):
              if self.finish:
                  raise StopIteration
              self.finish = True
              return self.data
  
          def __del__(self):
              pass
  
      calib_data = TestDataLoader(data)
  
      for quantize_granularity in quantize_granularity_list:
          qnet = quantization.quantize_net(
              net_original,
              device=mx.cpu(),
              exclude_layers=None,
              exclude_operators=None,
              quantized_dtype=out_type,
              calib_mode=calib_mode,
              calib_data=calib_data,
              num_calib_batches=1,
              quantize_mode=quantize_mode,
              quantize_granularity=quantize_granularity,
          )
          qsym, _ = qnet.export(None)
          if check_fusion:
              check_fusion_parameter(qsym, attrs_dict)
          if check_calibration:
              check_qsym_calibrated(qsym, out_type, name=name)
          if check_scale_align:
              check_qsym_scale_align(qsym)
  
          quantized_out = qnet(*data)
          if one_output:
              quantized_out = [quantized_out]
          for i in range(len(ref_out)):
              min_range = mx.np.min(ref_out[i]).item()
              max_range = mx.np.max(ref_out[i]).item()
              atol = 0.1 * max(abs(min_range), abs(max_range))
              assert_almost_equal_with_err(
                  quantized_out[i].asnumpy(),
                  ref_out[i].asnumpy(),
                  rtol=0.1,
                  atol=atol,
                  etol=0.2,
              )
  
imports: import mxnet
  import numpy
  import unittest
  import pytest
  import ctypes
  import copy
  from mxnet.contrib import quantization
  from mxnet.gluon import nn
  from mxnet.test_utils import assert_almost_equal, assert_almost_equal_with_err
label_desc: Use image node_id 4 for calling a global function with example usage: check_quantize(net_original, data_shapes, out_type, name, check_calibration, check_scale_align, quantize_mode, attrs_dict, calib_mode, check_fusion) and returns: self, self