code: def quantize(
      model,
      dataloader=None,
      eval_func=None,
      metric=None,
      thread_num=None,
      **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
  
      q_model = _quantize(
          model=model,
          dataloader=dataloader,
          eval_func=eval_func,
          metric=metric,
          **not_none_kwargs,
      )
  
      if "pytorch" in not_none_kwargs["framework"]:
          from .pytorch.quantized_model import PytorchQuantizedModel
  
          quantized_model = PytorchQuantizedModel(q_model, thread_num)
  
          from bigdl.nano.utils.pytorch import (
              patch_attrs_from_model_to_object,
          )
  
          patch_attrs_from_model_to_object(model, quantized_model)
          return quantized_model
  
      elif "tensorflow" in not_none_kwargs["framework"]:
          from .tensorflow.model import KerasQuantizedModel
  
          return KerasQuantizedModel(q_model)
  
      elif "onnx" in not_none_kwargs["framework"]:
          onnxruntime_session_options = not_none_kwargs.get(
              "onnxruntime_session_options", None
          )
          onnx_option = not_none_kwargs.get("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 bigdl.nano.deps.onnxruntime.tensorflow.model import (
                  KerasONNXRuntimeModel,
              )
  
              return KerasONNXRuntimeModel(
                  q_model.model,
                  onnxruntime_session_options=onnxruntime_session_options,
              )
          else:
              from bigdl.nano.deps.onnxruntime.pytorch.pytorch_onnxruntime_model import (
                  PytorchONNXRuntimeModel,
              )
  
              quantized_model = PytorchONNXRuntimeModel(
                  q_model.model, None, onnxruntime_session_options
              )
  
              from bigdl.nano.utils.pytorch import (
                  patch_attrs_from_model_to_object,
              )
  
              patch_attrs_from_model_to_object(model, quantized_model)
              return quantized_model
  
      else:
          invalidInputError(
              False,
              f"Invalid framework argument: {not_none_kwargs['framework']}",
          )
  
imports: from bigdl.nano.utils.common import invalidInputError
  from .core.base_metric import BaseINCMetric
  from bigdl.nano.utils.common import compare_version
  import operator
label_desc: Use image node_id 1 for calling a global function with example usage: quantize(model, dataloader, eval_func, metric, thread_num) and returns: quantized_model, KerasQuantizedModel, KerasONNXRuntimeModel, quantized_model