code: def test_magnitude_pruner_cloning(simple_module):
      model = simple_module
      config = MagnitudePrunerConfig.from_dict(
          {
              "global_config": {
                  "scheduler": {"update_steps": [0, 1]},
              }
          },
      )
      pruner = MagnitudePruner(model, config)
      pruner.prepare(inplace=True)
  
      model_copy = copy.deepcopy(model)
  
      assert hasattr(model_copy.conv2d, "pruning_method")
      assert torch.all(
          model_copy.conv2d.weight_orig == model.conv2d.weight_orig
      )
      assert torch.all(
          model_copy.conv2d.weight_mask == model.conv2d.weight_mask
      )
  
      pruner.finalize(inplace=True)
  
      model_copy_finalize = copy.deepcopy(model)
  
      assert not hasattr(model_copy_finalize.conv2d, "pruning_method")
      assert torch.all(
          model_copy_finalize.conv2d.weight == model.conv2d.weight
      )
  
imports: import copy
  from collections import OrderedDict
  import numpy
  import pytest
  import torch
  from coremltools.optimize.torch.pruning import MagnitudePruner, MagnitudePrunerConfig, ModuleMagnitudePrunerConfig
  from coremltools.optimize.torch.pruning._utils import n_m_mask
label_desc: Use image node_id 20 for calling a global function with example usage: test_magnitude_pruner_cloning(simple_module) without return types