code: def test_convert_palettized_source_model_custom():
      (
          model,
          inputs,
          torch_input_values,
          coreml_input_values,
      ) = get_test_model_and_data_complex()
  
      weight_1_unique = create_unique_weight(
          model.conv_1.weight, nbits=2
      )
      weight_2_unique = create_unique_weight(
          model.conv_2.weight, nbits=6
      )
      linear_1_unique = create_unique_weight(
          model.linear_1.weight, nbits=4
      )
  
      with torch.no_grad():
          model.conv_1.weight = torch.nn.Parameter(
              torch.Tensor(weight_1_unique)
          )
          model.conv_2.weight = torch.nn.Parameter(
              torch.Tensor(weight_2_unique)
          )
          model.linear_1.weight = torch.nn.Parameter(
              torch.Tensor(linear_1_unique)
          )
  
      pipeline = ct.PassPipeline.DEFAULT_PALETTIZATION
      config = cto.coreml.OptimizationConfig(
          global_config=cto.coreml.OpPalettizerConfig(mode="unique"),
          op_type_configs={
              "conv": None,
              "linear": cto.coreml.OpPalettizerConfig(
                  nbits=1, mode="kmeans"
              ),
          },
      )
      pipeline.set_options(
          "compression::palettize_weights", {"config": config}
      )
  
      torchmodel = torch.jit.trace(model, torch_input_values)
      mlmodel = ct.convert(
          torchmodel,
          inputs=inputs,
          convert_to="mlprogram",
          pass_pipeline=pipeline,
          compute_precision=ct.precision.FLOAT32,
          minimum_deployment_target=ct.target.iOS16,
      )
  
      expected_ops = [
          "constexpr_lut_to_dense",
          "constexpr_lut_to_dense",
          "conv",
          "conv",
          "reshape",
          "linear",
          "linear",
          "constexpr_lut_to_dense",
          "squeeze",
          "lstm",
          "expand_dims",
          "expand_dims",
      ]
      prog = mlmodel._mil_program
      assert get_op_types_in_program(prog) == expected_ops
  
      expected_nbits = [1, 1, 1, 1]
      lut_ops = prog.find_ops(op_type="constexpr_lut_to_dense")
  
      for nbits, op in zip(expected_nbits, lut_ops):
          assert op.lut.val.shape == (2**nbits,)
  
      conv_ops = prog.find_ops(op_type="conv")
      assert conv_ops[0].weight.op.op_type == "const"
      assert conv_ops[1].weight.op.op_type == "const"
  
      linear_ops = prog.find_ops(op_type="linear")
      assert linear_ops[0].weight.op.op_type == "constexpr_lut_to_dense"
      assert linear_ops[1].weight.op.op_type == "constexpr_lut_to_dense"
  
imports: import itertools
  import numpy
  import pytest
  import torch
  import coremltools
  import coremltools.optimize
  from coremltools._deps import _HAS_SKLEARN
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.testing_utils import get_op_types_in_program
  from coremltools.optimize.coreml._post_training_quantization import CoreMLWeightMetaData
  from coremltools.test.ml_program.test_compression import get_test_model_and_data
label_desc: Use image node_id 7 for calling the TestPalettizeWeights obj's underlying member method code with example usage: obj.test_convert_palettized_source_model_custom() without return types