class_docstr: This class is testing the api reference code in
  https://coremltools.readme.io/v7.0/docs/optimizetorch-api-overview
code: def test_load_from_yaml(self):
      def _test_config(config_path):
          import torch
  
          import coremltools as ct
          from coremltools.optimize.torch.pruning import (
              MagnitudePruner,
              MagnitudePrunerConfig,
          )
  
          # Toy example
          x, label = torch.rand(1, 3, 224, 224), torch.rand(
              1, 26, 206, 12
          )
          data = [(x, label)]
  
          model, loss_fn, optimizer = create_model_and_optimizer()
  
          # Initialize pruner and configure it
          # (original) config = MagnitudePrunerConfig.from_yaml("config.yaml")
          config = MagnitudePrunerConfig.from_yaml(config_path)
  
          pruner = MagnitudePruner(model, config)
  
          # Insert pruning layers in the model
          model = pruner.prepare()
  
          for inputs, labels in data:
              output = model(inputs)
              loss = loss_fn(output, labels)
              loss.backward()
              optimizer.step()
              pruner.step()
  
          # Commit pruning masks to model parameters
          pruner.finalize(inplace=True)
  
          # Export
          example_input = torch.rand(1, 3, 224, 224)
          traced_model = torch.jit.trace(model, example_input)
  
          coreml_model = ct.convert(
              traced_model,
              inputs=[ct.TensorType(shape=example_input.shape)],
              pass_pipeline=ct.PassPipeline.DEFAULT_PRUNING,
              minimum_deployment_target=ct.target.iOS16,
          )
          assert coreml_model is not None
          output_file = tempfile.NamedTemporaryFile(
              suffix=".mlpackage"
          ).name
          coreml_model.save(output_file)
  
      _test_config(self.get_global_config())
      _test_config(self.get_fine_grain_config())
  
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 3 for calling the TestOptimizeTorchAPIOverview obj's underlying member method code with example usage: obj.test_load_from_yaml() without return types