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)

    ``coremltools.compression_utils.palettize_weights`` is deprecated and will be removed in the future.
    Please use :py:class:`coremltools.optimize.coreml.palettize_weights`.
    
coremltools/models/ml_program/compression_utils.py