class_docstr: A structured pruning masker base class that prunes convolutional layer filters.
  
  Parameters
  ----------
  model: nn.Module
      model to be pruned
  pruner: Pruner
      A Pruner instance used to prune the model
  preserve_round: int
      after pruning, preserve filters/channels round to `preserve_round`, for example:
      for a Conv2d layer, output channel is 32, sparsity is 0.2, if preserve_round is
      1 (no preserve round), then there will be int(32 * 0.2) = 6 filters pruned, and
      32 - 6 = 26 filters are preserved. If preserve_round is 4, preserved filters will
      be round up to 28 (which can be divided by 4) and only 4 filters are pruned.
docstr: calculate the mask for `wrapper`.
  Parameters
  ----------
  sparsity: float/list of float
      The target sparsity of the wrapper. If we calculate the mask in
      the normal way, then sparsity is a float number. In contrast, if
      we calculate the mask in the dependency-aware way, sparsity is a
      list of float numbers, each float number corressponds to a sparsity
      of a layer.
  wrapper: PrunerModuleWrapper/list of PrunerModuleWrappers
      The wrapper of the target layer. If we calculate the mask in the normal
      way, then `wrapper` is an instance of PrunerModuleWrapper, else `wrapper`
      is a list of PrunerModuleWrapper.
  wrapper_idx: int/list of int
      The index of the wrapper.
  depen_kwargs: dict
      The kw_args for the dependency-aware mode.
docstr_tok: ["calculate","the","mask","for","`","wrapper","`",".","Parameters","--","--","--","--","--","sparsity",":","float\/list","of","float","The","target","sparsity","of","the","wrapper",".","If","we","calculate","the","mask","in","the","normal","way",",","then","sparsity","is","a","float","number",".","In","contrast",",","if","we","calculate","the","mask","in","the","dependency-aware","way",",","sparsity","is","a","list","of","float","numbers",",","each","float","number","corressponds","to","a","sparsity","of","a","layer",".","wrapper",":","PrunerModuleWrapper\/list","of","PrunerModuleWrappers","The","wrapper","of","the","target","layer",".","If","we","calculate","the","mask","in","the","normal","way",",","then","`","wrapper","`","is","an","instance","of","PrunerModuleWrapper",",","else","`","wrapper","`","is","a","list","of","PrunerModuleWrapper",".","wrapper_idx",":","int\/list","of","int","The","index","of","the","wrapper",".","depen_kwargs",":","dict","The","kw_args","for","the","dependency-aware","mode","."]
code: def calc_mask(
      self, sparsity, wrapper, wrapper_idx=None, **depen_kwargs
  ):
      """
      calculate the mask for `wrapper`.
      Parameters
      ----------
      sparsity: float/list of float
          The target sparsity of the wrapper. If we calculate the mask in
          the normal way, then sparsity is a float number. In contrast, if
          we calculate the mask in the dependency-aware way, sparsity is a
          list of float numbers, each float number corressponds to a sparsity
          of a layer.
      wrapper: PrunerModuleWrapper/list of PrunerModuleWrappers
          The wrapper of the target layer. If we calculate the mask in the normal
          way, then `wrapper` is an instance of PrunerModuleWrapper, else `wrapper`
          is a list of PrunerModuleWrapper.
      wrapper_idx: int/list of int
          The index of the wrapper.
      depen_kwargs: dict
          The kw_args for the dependency-aware mode.
      """
      if not self.dependency_aware:
          # calculate the mask in the normal way, each layer calculate its
          # own mask separately
          return self._normal_calc_mask(sparsity, wrapper, wrapper_idx)
      else:
          # if the dependency_aware switch is on, then calculate the mask
          # in the dependency-aware way
          return self._dependency_calc_mask(
              sparsity, wrapper, wrapper_idx, **depen_kwargs
          )
  
imports: import logging
  import math
  import numpy
  import torch
  from .weight_masker import WeightMasker
label_desc: Use image node_id 2 for calling the StructuredWeightMasker obj's underlying member method code with example usage: obj.calc_mask(sparsity, wrapper, wrapper_idx) and returns: self, self