class_docstr: This class is testing the api reference code in
  https://coremltools.readme.io/v7.0/docs/optimizecoreml-api-overview
code: def test_6_bit_palettization_example(self):
      import coremltools as ct
      import coremltools.optimize.coreml as cto
  
      # load model
      # (original) mlmodel = ct.models.MLModel(uncompressed_model_path)
      mlmodel = get_mlmodel()
  
      # define op config
      op_config = cto.OpPalettizerConfig(mode="kmeans", nbits=6)
  
      # define optimization config by applying the op config globally to all ops
      config = cto.OptimizationConfig(global_config=op_config)
  
      # palettize weights
      compressed_mlmodel = cto.palettize_weights(mlmodel, config)
  
      # Do some basic checks
      assert compressed_mlmodel is not None
      ops = get_op_types_in_program(compressed_mlmodel._mil_program)
      assert ops.count("constexpr_lut_to_dense") == 6
  
imports: import tempfile
  from coremltools.converters.mil.testing_utils import get_op_types_in_program
  from coremltools.test.optimize.coreml.test_passes import TestCompressionPasses
  from coremltools.test.optimize.coreml.test_passes import TestConfigurationFromDictFromYaml
label_desc: Use image node_id 1 for calling the TestOptimizeCoremlAPIOverview obj's underlying member method code with example usage: obj.test_6_bit_palettization_example() without return types