code: def test_weight_palettization_stress(mode):
      (
          model,
          inputs,
          torch_input_values,
          coreml_input_values,
      ) = get_test_model_and_data()
      torchmodel = torch.jit.trace(model, torch_input_values)
      mlmodel = ct.convert(
          torchmodel, inputs=inputs, convert_to="mlprogram"
      )
      mlmodel_palettized = palettize_weights(
          mlmodel, nbits=4, mode=mode
      )
  
      # validate parameters
      expected_ops = ["constexpr_lut_to_dense", "cast", "conv", "cast"]
      assert (
          get_op_types_in_program(mlmodel_palettized._mil_program)
          == expected_ops
      )
  
      main_func = mlmodel_palettized._mil_program.functions["main"]
      lut_to_dense_op = main_func.find_ops(
          op_type="constexpr_lut_to_dense"
      )[0]
  
      assert lut_to_dense_op.shape.val.tolist() == list(
          model.weight.detach().numpy().shape
      )
  
      # validate the model
      verify_model_outputs(
          mlmodel, mlmodel_palettized, coreml_input_values
      )
  
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 2 for calling the TestPalettizeWeights obj's underlying member method code with example usage: obj.test_weight_palettization_stress(mode) without return types