code: def _quantize_general(
      context,
      node,
      input: Var,
      scale_var: Var,
      zero_point_var: Var,
      torch_dtype_var: Var,
      axis: int = None,
  ):
      scale = scale_var.val
      if scale is None:
          raise ValueError(
              "quantization scale must be const at compile time"
          )
      if len(scale.shape) > 0 and _np.prod(scale.shape) == 1:
          scale = scale.reshape(-1)[0]
          axis = None
  
      zero_point = zero_point_var.val
      if zero_point is None:
          raise ValueError(
              "quantization zero point must be const at compile time"
          )
      if len(zero_point.shape) > 0 and _np.prod(zero_point.shape) == 1:
          zero_point = zero_point.reshape(-1)[0]
  
      torch_dtype = NUM_TO_TORCH_DTYPE.get(torch_dtype_var.val)
      if torch_dtype is None:
          raise ValueError(
              "quantization dtype must be const at compile time"
          )
      dtype = TORCH_QTYPE_TO_STR.get(torch_dtype)
      # pytorch quantization dtype can be int32, which is not supported in MIL
      if dtype is None:
          raise ValueError(
              "MIL quantization dtype must be int8 or uint8"
          )
  
      # perf: all 0 zero point can be no zero point in MIL
      if zero_point is not None and _np.all(zero_point == 0):
          zero_point = None
  
      # make sure zero point dtype is consistent with quantization dtype,
      # since torch may provide int32 zero point
      if zero_point is not None:
          if (
              dtype == "int8"
              and _np.all(-128 <= zero_point)
              and _np.all(zero_point < 128)
          ):
              zero_point = zero_point.astype(_np.int8)
          elif (
              dtype == "uint8"
              and _np.all(0 <= zero_point)
              and _np.all(zero_point < 256)
          ):
              zero_point = zero_point.astype(_np.uint8)
          else:
              raise ValueError(
                  "cannot fit zero point into quantization dtype"
              )
  
      result = mb.quantize(
          input=input,
          zero_point=zero_point,
          scale=scale,
          output_dtype=dtype,
          axis=axis,
      )
      context.add(result, node.name)
      context.quant_context.add_quantization_info(
          node.name, torch_dtype, scale, zero_point, axis
      )
  
imports: import numpy
  import torch
  from coremltools import _logger
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Var, types
  from .ops import NUM_TO_TORCH_DTYPE, _create_linear_layer, _get_inputs, promote_input_dtypes
  from .torch_op_registry import register_torch_op
label_desc: Use image node_id 1 for calling a global function with example usage: _quantize_general(context, node, input, scale_var, zero_point_var, torch_dtype_var, axis) without return types