code: def _quantize_wp(wp, nbits, qm, axis=0, **kwargs):
      """
      Quantize the weight blob
  
      wp: numpy.array
          Weight parameters
      nbits: int
          Number of bits
      qm:
          Quantization mode
      lut_function: (``callable function``)
          Python callable representing a look-up table
  
      Returns
      -------
      scale: numpy.array
          Per-channel scale
      bias: numpy.array
          Per-channel bias
      lut: numpy.array
          Lookup table
      quantized_wp: numpy.array
          Quantized weight of same shape as wp, with dtype numpy.uint8
      """
  
      scale = bias = lut = None
  
      # Linear Quantization
      if qm in [
          _QUANTIZATION_MODE_LINEAR_QUANTIZATION,
          _QUANTIZATION_MODE_LINEAR_SYMMETRIC,
      ]:
          symmetric = qm == _QUANTIZATION_MODE_LINEAR_SYMMETRIC
          qw, scale, bias = _quantize_channelwise_linear(
              wp, nbits, axis, symmetric
          )
      # Lookup tables
      elif qm == _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS:
          lut, qw = _get_kmeans_lookup_table_and_weight(nbits, wp)
      elif qm == _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE:
          if "lut_function" not in kwargs.keys():
              raise Exception(
                  "Custom lookup table quantization mode "
                  "selected but no lookup table function passed"
              )
          lut_function = kwargs["lut_function"]
          if not callable(lut_function):
              raise Exception(
                  "Argument for Lookup Table passed in but is "
                  "not callable"
              )
          try:
              lut, qw = lut_function(nbits, wp)
          except Exception as e:
              raise Exception(
                  "{}\nCall to Lookup Table function failed".format(
                      e.message
                  )
              )
      elif qm == _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR:
          lut, qw = _get_linear_lookup_table_and_weight(nbits, wp)
      else:
          raise NotImplementedError(
              'Quantization method "{}" not supported'.format(qm)
          )
  
      quantized_wp = _np.uint8(qw)
      return scale, bias, lut, quantized_wp
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import numpy
  from sys import stdout
  from os import listdir
  from six import string_types
  from .optimization_utils import _optimize_nn
  from coremltools.models import _SUPPORTED_QUANTIZATION_MODES, _QUANTIZATION_MODE_DEQUANTIZE, _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR, _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS, _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE, _QUANTIZATION_MODE_LINEAR_QUANTIZATION, _QUANTIZATION_MODE_LINEAR_SYMMETRIC, _LUT_BASED_QUANTIZATION
  from ..utils import _get_nn_layers, _wp_to_fp16wp, _get_model, _macos_version
  from ..._deps import _HAS_SKLEARN
  from ...None import _MINIMUM_QUANTIZED_MODEL_SPEC_VERSION, _MINIMUM_FP16_SPEC_VERSION, _SPECIFICATION_VERSION_IOS_14
label_desc: Use image node_id 7 for calling a global function with example usage: _quantize_wp(wp, nbits, qm, axis) and returns: scale,  bias,  lut,  quantized_wp