code: def quantize_graph(
      sym,
      arg_params,
      aux_params,
      device=cpu(),
      excluded_sym_names=None,
      excluded_op_names=None,
      calib_mode="entropy",
      quantized_dtype="int8",
      quantize_mode="full",
      quantize_granularity="tensor-wise",
      LayerOutputCollector=None,
      logger=None,
  ):
      """User-level API for generating a quantized model from a FP32 model w/o calibration
      and a collector for naive or entropy calibration.
      The backend quantized operators are only enabled for Linux systems. Please do not run
      inference using the quantized models on Windows for now.
  
      Parameters
      ----------
      sym : Symbol
          Defines the structure of a neural network for FP32 data types.
      device : Device
          Defines the device that users want to run forward propagation on the calibration
          dataset for collecting layer output statistics. Currently, only supports single device.
      arg_params : dict
          Dictionary of name to `NDArray`.
      aux_params : dict
          Dictionary of name to `NDArray`.
      excluded_sym_names : list of strings
          A list of strings representing the names of the symbols that users want to excluding
          from being quantized.
      excluded_op_names : list of strings
          A list of strings representing the names of the operators that users want to excluding
      calib_mode : str
          If calib_mode='none', no calibration will be used and the thresholds for
          requantization after the corresponding layers will be calculated at runtime by
          calling min and max operators. The quantized models generated in this
          mode are normally 10-20% slower than those with calibrations during inference.
          If calib_mode='naive', the min and max values of the layer outputs from a calibration
          dataset will be directly taken as the thresholds for quantization.
          If calib_mode='entropy' (default mode), the thresholds for quantization will be
          derived such that the KL divergence between the distributions of FP32 layer outputs and
          quantized layer outputs is minimized based upon the calibration dataset.
      quantized_dtype : str
          The quantized destination type for input data. Currently support 'int8'
          , 'uint8' and 'auto'. 'auto' means automatically select output type according to calibration result.
          Default value is 'int8'.
      quantize_mode : str
          The mode that quantization pass to apply. Support 'full' and 'smart'.
          'full' means quantize all operator if possible.
          'smart' means quantization pass will smartly choice which operator should be quantized.
      quantize_granularity : str
          The granularity of quantization, currently supports 'tensor-wise' and 'channel-wise'
          quantization. The default value is 'tensor-wise'.
      LayerOutputCollector : subclass of CalibrationCollector
          For custom calibration method usage.
          Passed object's include_layers attribute will be feed with names of layers which needs calibration
      logger : Object
          A logging object for printing information during the process of quantization.
      Returns
      -------
      quantized_model : tuple
          A tuple of quantized symbol, quantized arg_params, aux_params and collector.
      """
      if excluded_sym_names is None:
          excluded_sym_names = []
      if not isinstance(excluded_sym_names, list):
          raise ValueError(
              "excluded_sym_names must be a list of strings representing"
              " the names of the symbols that will not be quantized,"
              f" while received type {str(type(excluded_sym_names))}"
          )
      if not isinstance(device, Device):
          raise ValueError(
              f"currently only supports single device, while received {str(device)}"
          )
      if logger:
          os.environ["MXNET_QUANTIZATION_VERBOSE"] = "1"
          logger.info("Quantizing graph")
      if quantized_dtype not in ("int8", "uint8", "auto"):
          raise ValueError(
              f"unknown quantized_dtype {quantized_dtype} received,"
              " expected `int8`, `uint8` or `auto`"
          )
      if quantize_granularity not in ("tensor-wise", "channel-wise"):
          raise ValueError(
              f"unkonwn quantize_granularity {quantize_granularity} received,"
              " expected `tensor-wise` or `channel-wise`."
          )
      qsym, calib_layers = _quantize_symbol(
          sym,
          device,
          excluded_symbols=excluded_sym_names,
          excluded_operators=excluded_op_names,
          offline_params=list(arg_params.keys()),
          quantized_dtype=quantized_dtype,
          quantize_mode=quantize_mode,
          quantize_granularity=quantize_granularity,
      )
  
      collector = None
      if calib_mode is not None and calib_mode != "none":
          if calib_mode == "entropy":
              collector = _LayerHistogramCollector(
                  quantized_dtype=quantized_dtype,
                  include_layers=calib_layers,
                  logger=logger,
              )
              if logger:
                  logger.info(
                      "Create a layer output collector for entropy calibration."
                  )
          elif calib_mode == "naive":
              collector = _LayerOutputMinMaxCollector(
                  quantized_dtype=quantized_dtype,
                  include_layers=calib_layers,
                  logger=logger,
              )
              if logger:
                  logger.info(
                      "Create a layer output minmax collector for naive calibration"
                  )
          elif (
              calib_mode == "custom"
              and LayerOutputCollector is not None
          ):
              if not isinstance(
                  LayerOutputCollector, CalibrationCollector
              ):
                  raise ValueError(
                      "LayerOutputCollecotr must be a subclass of a CalibrationCollector class,"
                      f" but it is {LayerOutputCollector.__class__}"
                  )
              collector = LayerOutputCollector
  
              # Inject layer names that need calibration to collector
              if hasattr(collector, "include_layers"):
                  if collector.include_layers is not None:
                      logger.info(
                          "Custom collector has set include_layers attribute. "
                          "Calibration layers not passed"
                      )
                  else:
                      collector.include_layers = calib_layers
              if logger:
                  logger.info(
                      "Create a custom layer output minmax collector for calibration"
                  )
          else:
              raise ValueError(
                  f"unknown calibration mode {calib_mode} received,"
                  " expected `none`, `naive`, `entropy` or `custom`"
              )
          if logger:
              logger.info(
                  "Collector created, please use set_monitor_callback"
                  " to collect calibration information."
              )
  
      if logger:
          logger.info("Quantizing parameters")
      qarg_params = _quantize_params(qsym, arg_params, min_max_dict={})
  
      if is_np_array():
          qsym = qsym.as_np_ndarray()
  
      return qsym, qarg_params, aux_params, collector, calib_layers
  
imports: import abc
  import ctypes
  import logging
  import os
  import warnings
  import numpy
  import mxnet
  from ..base import _LIB, check_call, py_str
  from ..base import c_array, c_str, mx_uint, mx_real_t, c_str_array
  from ..base import SymbolHandle
  from ..symbol import Symbol
  from ..None import ndarray
  from ..io import DataDesc
  from ..device import cpu, Device
  from ..util import is_np_array, wrap_ctx_to_device_func
label_desc: Use image node_id 9 for calling a global function with example usage: quantize_graph(sym, arg_params, aux_params, device, excluded_sym_names, excluded_op_names, calib_mode, quantized_dtype, quantize_mode, quantize_granularity, LayerOutputCollector, logger) and returns: qsym,  qarg_params,  aux_params,  collector,  calib_layers