code: def affine_quantize_weights(
      mlmodel, mode="linear_symmetric", op_selector=None, dtype=_np.int8
  ):
      """
      ``coremltools.compression_utils.affine_quantize_weights`` is deprecated and will be removed in the future.
      Please use :py:class:`coremltools.optimize.coreml.linear_quantize_weights`.
      """
      if op_selector is None:
          op_selector = _default_op_selector
  
      op_config = _OpLinearQuantizerConfig(
          mode=mode, dtype=dtype, weight_threshold=None
      )
      config = _OptimizationConfig(
          global_config=op_config,
          is_deprecated=True,
          op_selector=op_selector,
      )
      return _linear_quantize_weights(mlmodel, config)
  
file_path: coremltools/coremltools/models/ml_program/compression_utils.py
imports: import numpy
  from coremltools.converters.mil import Operation
  from coremltools.models._deprecation import deprecated
  from coremltools.optimize.coreml import OpLinearQuantizerConfig, OpMagnitudePrunerConfig, OpPalettizerConfig, OpThresholdPrunerConfig, OptimizationConfig
  from coremltools.optimize.coreml import linear_quantize_weights, decompress_weights, palettize_weights, prune_weights
label_desc: Use image node_id 2 for calling a global function with example usage: affine_quantize_weights(mlmodel, mode, op_selector, dtype) and returns: _linear_quantize_weights