class_docstr: Weight-Norm Sparsifier
  
  This sparsifier computes the norm of every sparse block and "zeroes-out" the
  ones with the lowest norm. The level of sparsity defines how many of the
  blocks is removed.
  
  This sparsifier is controlled by three variables:
  1. `sparsity_level` defines the number of *sparse blocks* that are zeroed-out
  2. `sparse_block_shape` defines the shape of the sparse blocks. Note that
      the sparse blocks originate at the zero-index of the tensor.
  3. `zeros_per_block` is the number of zeros that we are expecting in each
      sparse block. By default we assume that all elements within a block are
      zeroed-out. However, setting this variable sets the target number of
      zeros per block. The zeros within each block are chosen as the *smallest
      absolute values*.
  
  Args:
  
      sparsity_level: The target level of sparsity
      sparse_block_shape: The shape of a sparse block (see note below)
      zeros_per_block: Number of zeros in a sparse block
      norm: Norm to use. Could be either `int` or a callable.
          If `int`, only L1 and L2 are implemented.
  
  Note::
      The `sparse_block_shape` is tuple representing (block_ROWS, block_COLS),
      irrespective of what the rows / cols mean in the data tensor. That means,
      if you were to sparsify a weight tensor in the nn.Linear, which has a
      weight shape `(Cout, Cin)`, the `block_ROWS` would refer to the output
      channels, while the `block_COLS` would refer to the input channels.
  
  Note::
      All arguments to the WeightNormSparsifier constructor are "default"
      arguments and could be overriden by the configuration provided in the
      `prepare` step.
docstr: Creates patches of size `block_shape` after scattering the indices.
docstr_tok: ["Creates","patches","of","size","`","block_shape","`","after","scattering","the","indices","."]
code: def _scatter_fold_block_mask(
      self,
      output_shape,
      dim,
      indices,
      block_shape,
      mask=None,
      input_shape=None,
      device=None,
  ):
      r"""Creates patches of size `block_shape` after scattering the indices."""
      if mask is None:
          assert input_shape is not None
          mask = torch.ones(input_shape, device=device)
      mask.scatter_(dim=dim, index=indices, value=0)
      mask.data = F.fold(
          mask,
          output_size=output_shape,
          kernel_size=block_shape,
          stride=block_shape,
      )
      return mask
  
file_path: pytorch/torch/ao/pruning/sparsifier/weight_norm_sparsifier.py
imports: from functools import reduce
  from typing import Callable, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from .base_sparsifier import BaseSparsifier
  import operator
label_desc: Use image node_id 2 for calling the WeightNormSparsifier obj's underlying member method code with example usage: obj._scatter_fold_block_mask(output_shape, dim, indices, block_shape, mask, input_shape, device) and returns: mask