class_docstr: Test case for the implementation of paper:
  `Filter Pruning via Geometric Median for Deep Convolutional Neural Networks Acceleration <https://arxiv.org/abs/1811.00250>`_.
class_docstr_tok: ["Test","case","for","the","implementation","of","paper",":","`","Filter","Pruning","via","Geometric","Median","for","Deep","Convolutional","Neural","Networks","Acceleration","<","https",":","\/\/arxiv.org\/abs\/1811.00250",">","`","_","."]
code: def _test_update_mask_on_multiple_layer(
      self, expected_conv1, expected_conv2, device
  ):
      # the second setting
      model = TestFPGMPruner.SimpleConvFPGM().to(device)
      x = torch.ones((1, 1, 32, 32), device=device)
      pruner = FPGMPruner(0.3)
      config = [
          {"tensor_fqn": "conv2d1.weight"},
          {"tensor_fqn": "conv2d2.weight", "sparsity_level": 0.5},
      ]
      pruner.prepare(model, config)
      pruner.enable_mask_update = True
      pruner.step()
      # Get the masks for the two least-norm filters
      mask1 = (
          pruner.groups[0]["module"].parametrizations.weight[0].mask[-1]
      )
      mask2 = (
          pruner.groups[0]["module"].parametrizations.weight[0].mask[-2]
      )
      # Check if either of the least-norm filters is not pruned
      assert (
          mask1.item() is not False or mask2.item() is not False
      ), "Do not prune all least-norm filters"
  
      # fusion step
      pruned_model = pruner.prune()
      pruned_y = pruned_model(x)
      # assert shapes
      expected_conv1 = expected_conv1.to(device)
      expected_conv2 = expected_conv2.to(device)
      assert pruned_y.shape == (1, 2, 32, 32)
      assert pruned_model.conv2d1.weight.shape == expected_conv1.shape
      assert pruned_model.conv2d2.weight.shape == expected_conv2.shape
      # assert values
      assert torch.isclose(
          pruned_model.conv2d1.weight,
          expected_conv1,
          rtol=1e-05,
          atol=1e-07,
      ).all()
      assert torch.isclose(
          pruned_model.conv2d2.weight,
          expected_conv2,
          rtol=1e-05,
          atol=1e-07,
      ).all()
  
imports: import copy
  import logging
  import random
  import torch
  from torch import nn
  from torch.ao.pruning._experimental.pruner import SaliencyPruner, LSTMSaliencyPruner, BaseStructuredSparsifier, FakeStructuredSparsity, FPGMPruner
  from torch.nn.utils import parametrize
  from torch.testing._internal.common_utils import TestCase, skipIfTorchDynamo
  from torch.testing._internal.common_pruning import SimpleLinear, LinearBias, LinearActivation, LinearActivationFunctional, SimpleConv2d, Conv2dBias, Conv2dActivation, Conv2dPadBias, Conv2dPool, Conv2dPoolFlatten, Conv2dPoolFlattenFunctional, LSTMLinearModel, LSTMLayerNormLinearModel, rows_are_subset
label_desc: Use image node_id 3 for calling the TestFPGMPruner obj's underlying member method code with example usage: obj._test_update_mask_on_multiple_layer(expected_conv1, expected_conv2, device) without return types