code: def test_pruning():
      (
          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()
      global_config = cto.coreml.OpMagnitudePrunerConfig(
          target_sparsity=0.9, weight_threshold=500
      )
  
      config.set_global(global_config)
      config.set_op_type("lstm", None)
      config.set_op_name("linear_0", None)
  
      mlmodel = cto.coreml.prune_weights(mlmodel, config)
      expected_ops = [
          "constexpr_sparse_to_dense",
          "constexpr_sparse_to_dense",
          "constexpr_sparse_to_dense",
          "conv",
          "conv",
          "reshape",
          "linear",
          "linear",
          "lstm",
          "expand_dims",
          "expand_dims",
      ]
      prog = mlmodel._mil_program
      assert get_op_types_in_program(prog) == expected_ops
      assert (
          prog.find_ops(op_type="linear")[0].weight.op.op_type
          == "const"
      )
  
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 TestPruneWeights obj's underlying member method code with example usage: obj.test_pruning() without return types