code: def palettize_weights(
      mlmodel,
      nbits=None,
      mode="kmeans",
      op_selector=None,
      lut_function=None,
  ):
      """
      ``coremltools.compression_utils.palettize_weights`` is deprecated and will be removed in the future.
      Please use :py:class:`coremltools.optimize.coreml.palettize_weights`.
      """
      if op_selector is None:
          op_selector = _default_op_selector
  
      op_config = _OpPalettizerConfig(
          nbits=nbits,
          mode=mode,
          lut_function=lut_function,
          weight_threshold=None,
      )
      config = _OptimizationConfig(
          global_config=op_config,
          is_deprecated=True,
          op_selector=op_selector,
      )
      return _palettize_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 3 for calling a global function with example usage: palettize_weights(mlmodel, nbits, mode, op_selector, lut_function) and returns: _palettize_weights