code: def test_linear_quantization():
      (
          model,
          inputs,
          torch_input_values,
          coreml_input_values,
      ) = get_test_model_and_data_complex()
      torchmodel = torch.jit.trace(model, torch_input_values)
      mlmodel = ct.convert(
          torchmodel,
          inputs=inputs,
          convert_to="mlprogram",
          compute_precision=ct.precision.FLOAT32,
      )
  
      config = cto.coreml.OptimizationConfig()
      conv_config = cto.coreml.OpLinearQuantizerConfig(
          mode="linear_symmetric", dtype=np.int8, weight_threshold=500
      )
      lstm_config = cto.coreml.OpLinearQuantizerConfig(
          mode="linear", dtype=np.uint8, weight_threshold=4800
      )
  
      config.set_op_type("conv", conv_config)
      config.set_op_type("lstm", lstm_config)
      config.set_op_name("conv_2_1", None)
  
      mlmodel = cto.coreml.linear_quantize_weights(mlmodel, config)
      expected_ops = [
          "constexpr_affine_dequantize",
          "conv",
          "conv",
          "reshape",
          "linear",
          "linear",
          "constexpr_affine_dequantize",
          "constexpr_affine_dequantize",
          "constexpr_affine_dequantize",
          "lstm",
          "expand_dims",
          "expand_dims",
      ]
      prog = mlmodel._mil_program
      assert get_op_types_in_program(prog) == expected_ops
      assert (
          prog.find_ops(op_type="conv")[1].weight.op.op_type == "const"
      )
  
      expected_dtype = [np.int8, np.uint8, np.uint8, np.uint8, np.uint8]
      affine_ops = prog.find_ops(op_type="constexpr_affine_dequantize")
      for dtype, op in zip(expected_dtype, affine_ops):
          assert op.quantized_data.val.dtype == dtype
  
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 1 for calling the TestLinearQuantizeWeights obj's underlying member method code with example usage: obj.test_linear_quantization() without return types