code: def quantize(
      model,
      dataloader=None,
      eval_func=None,
      metric=None,
      thread_num=None,
      **kwargs,
  ):
      if compare_version("neural_compressor", operator.ge, "2.0"):
          from .inc_api_2 import quantize
  
          return quantize(
              model, dataloader, eval_func, metric, thread_num, **kwargs
          )
  
      if kwargs["approach"] not in ["static", "dynamic"]:
          invalidInputError(
              False,
              "Approach should be 'static' or 'dynamic', "
              "{} is invalid.".format(kwargs["approach"]),
          )
      not_none_kwargs = {}
      for k, v in kwargs.items():
          # pop None values to use default
          if v is not None:
              not_none_kwargs[k] = v
      approach_map = {
          "static": "post_training_static_quant",
          "dynamic": "post_training_dynamic_quant",
      }
      not_none_kwargs["approach"] = approach_map.get(
          kwargs["approach"], None
      )
      quantizer = None
      onnxruntime_session_options = not_none_kwargs.pop(
          "onnxruntime_session_options", None
      )
      if "pytorch" in not_none_kwargs["framework"]:
          from .pytorch.quantization import PytorchQuantization
  
          quantizer = PytorchQuantization(
              thread_num=thread_num, **not_none_kwargs
          )
      if "onnx" in not_none_kwargs["framework"]:
          onnx_option = not_none_kwargs.pop("onnx_option", None)
          if onnxruntime_session_options is None:
              import onnxruntime
  
              onnxruntime_session_options = onnxruntime.SessionOptions()
          if thread_num is not None:
              onnxruntime_session_options.intra_op_num_threads = (
                  thread_num
              )
              onnxruntime_session_options.inter_op_num_threads = (
                  thread_num
              )
          if onnx_option == "tensorflow":
              from .onnx.tensorflow.quantization import (
                  KerasONNXRuntimeQuantization,
              )
  
              quantizer = KerasONNXRuntimeQuantization(
                  onnxruntime_session_options=onnxruntime_session_options,
                  **not_none_kwargs,
              )
          else:
              from .onnx.pytorch.quantization import (
                  PytorchONNXRuntimeQuantization,
              )
  
              quantizer = PytorchONNXRuntimeQuantization(
                  onnxruntime_session_options=onnxruntime_session_options,
                  **not_none_kwargs,
              )
      if "tensorflow" in not_none_kwargs["framework"]:
          from .tensorflow.quantization import TensorflowQuantization
  
          quantizer = TensorflowQuantization(**not_none_kwargs)
      if not quantizer:
          # default quantization
          from .core import BaseQuantization
  
          quantizer = BaseQuantization(**not_none_kwargs)
      return quantizer.post_training_quantize(model, dataloader, metric)
  
imports: import operator
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.utils.common import compare_version
label_desc: Use image node_id 2 for calling a global function with example usage: quantize(model, dataloader, eval_func, metric, thread_num) and returns: quantizer, quantize