class_docstr: Base class for structured pruning.
  
  Abstract methods that need to be implemented:
      - update_mask: Function to compute a new mask for all keys in the
          `groups` attribute.
  
  Args:
      - defaults [dict]: default configurations will be attached to the
          configuration. Only the keys that don't exist in the `config` will
          be updated.
docstr: This function will attach the FakeStructuredSparsity parameterizations
  and BiasHooks at the appropriate points in the model.
docstr_tok: ["This","function","will","attach","the","FakeStructuredSparsity","parameterizations","and","BiasHooks","at","the","appropriate","points","in","the","model","."]
code: def _prepare(self, *args, **kwargs) -> None:
      r"""This function will attach the FakeStructuredSparsity parameterizations
      and BiasHooks at the appropriate points in the model.
      """
      for config in self.groups:
          module = config["module"]
          tensor_name = config["tensor_name"]
          parametrization = config.get(
              "parametrization", FakeStructuredSparsity
          )
          tensor = getattr(module, tensor_name)
  
          mask = config.get(
              "mask",
              torch.ones(
                  tensor.shape[0],
                  dtype=torch.bool,
                  device=tensor.device,
              ),
          )
          self.state[config["tensor_fqn"]]["mask"] = mask
          parametrize.register_parametrization(
              module, tensor_name, parametrization(mask)
          )
  
          # if linear / conv, we add in bias hooks
          if isinstance(module, (nn.Linear, nn.Conv2d)):
              prune_bias = config.get("prune_bias", True)
              if module.bias is not None:
                  module.register_parameter(
                      "_bias", nn.Parameter(module.bias.detach())
                  )
                  module.bias = None
                  module.prune_bias = prune_bias
  
              module.register_forward_hook(
                  BiasHook(
                      module.parametrizations.weight[0], prune_bias
                  )
              )
  
imports: from itertools import chain
  from operator import getitem
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.fx import symbolic_trace
  from torch.nn.utils import parametrize
  from typing import Type, Set, Dict, Callable, Tuple, Optional, Union
  from torch.ao.pruning import BaseSparsifier
  from .parametrization import FakeStructuredSparsity, BiasHook, module_contains_param
  from .match_utils import apply_match, MatchAllNode
  from .prune_functions import prune_linear, prune_linear_linear, prune_linear_activation_linear, prune_conv2d, prune_conv2d_conv2d, prune_conv2d_activation_conv2d, prune_conv2d_activation_pool_conv2d, prune_conv2d_pool_activation_conv2d, prune_conv2d_pool_flatten_linear, prune_lstm_output_linear, prune_lstm_output_layernorm_linear
label_desc: Use image node_id 3 for calling the BaseStructuredSparsifier obj's underlying member method code with example usage: obj._prepare() without return types