code: def _quantize_channelwise_linear(
      weight, nbits, axis=0, symmetric=False
  ):
      """
      Linearly quantize weight blob.
  
      weight: numpy.array
          Weight to be quantized.
  
      nbits: int
          Number of bits per weight element
  
      axis: int
          Axis of the weight blob to compute channel-wise quantization, can be 0 or 1
  
      symmetric: bool
          If true, set quantization range to be symmetrical to 0.
          Otherwise, set quantization range to be the minimum and maximum of
          weight parameters.
  
      Returns
      -------
      quantized_weight: numpy.array
          quantized weight as float numpy array, with the same shape as weight
      scale: numpy.array
          per channel scale
      bias: numpy.array
          per channel bias
      """
      if len(weight.shape) == 1:  # vector situation, treat as 1 channel
          weight = weight.reshape((1, weight.shape[0]))
  
      rank = len(weight.shape)
      if axis == 1:
          transposed_axis_order = (1, 0) + tuple(range(2, rank))
          weight = _np.transpose(weight, transposed_axis_order)
  
      num_channels = weight.shape[0]
      shape = weight.shape
      weight = weight.reshape((num_channels, -1))  # [C, L]
  
      a = _np.amin(weight, axis=-1)  # [C,]
      b = _np.amax(weight, axis=-1)  # [C,]
  
      if symmetric:
          r = _np.maximum(_np.abs(a), _np.abs(b))
          scale = r / ((1 << nbits) / 2.0 - 1)
          bias = -(1 << nbits) / 2.0 * scale
          num = weight - bias[:, None]
          denom = scale[:, None]
          qw = _np.divide(
              num,
              denom,
              out=_np.zeros_like(num),
              where=(_np.abs(denom) > 1e-6),
          )
          qw = _np.round(qw)
      else:
          qb = (1 << nbits) - 1
          scale = (b - a) / qb
          inv_scale = _np.divide(
              1.0,
              scale,
              out=_np.zeros_like(scale),
              where=(_np.abs(scale) > 1e-6),
          )
          bias = a
          qw = (weight - a[:, None]) * inv_scale[:, None]
          qw = _np.round(qw)
  
      # Reshape
      quantized_weight = qw.reshape(shape)
      if axis == 1:
          quantized_weight = _np.transpose(
              quantized_weight, transposed_axis_order
          )
  
      return (quantized_weight, scale, bias)
  
imports: from os import listdir
  from sys import stdout
  import numpy
  from coremltools import ComputeUnit, _logger
  from coremltools._deps import _HAS_KMEANS1D, _kmeans1d
  from coremltools.models import _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE, _QUANTIZATION_MODE_DEQUANTIZE, _QUANTIZATION_MODE_LINEAR_QUANTIZATION, _QUANTIZATION_MODE_LINEAR_SYMMETRIC, _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS, _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR, _SUPPORTED_QUANTIZATION_MODES, MLModel
  from ...None import _MINIMUM_FP16_SPEC_VERSION, _MINIMUM_QUANTIZED_MODEL_SPEC_VERSION, _SPECIFICATION_VERSION_IOS_14
  from ..utils import _get_model, _macos_version, _wp_to_fp16wp
  from .optimization_utils import _optimize_nn
label_desc: Use image node_id 6 for calling a global function with example usage: _quantize_channelwise_linear(weight, nbits, axis, symmetric) and returns: quantized_weight,  scale,  bias