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.
class_docstr_tok: ["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 of given layer.
  Parameters
  ----------
  sparsity: float
      pruning ratio,  preserved weight ratio is `1 - sparsity`
  wrapper: PrunerModuleWrapper
      layer wrapper of this layer
  wrapper_idx: int
      index of this wrapper in pruner's all wrappers
  Returns
  -------
  dict
      dictionary for storing masks, keys of the dict:
      'weight_mask':  weight mask tensor
      'bias_mask': bias mask tensor (optional)
docstr_tok: ["Calculate","the","mask","of","given","layer",".","Parameters","--","--","--","--","--","sparsity",":","float","pruning","ratio",",","preserved","weight","ratio","is","`","1","-","sparsity","`","wrapper",":","PrunerModuleWrapper","layer","wrapper","of","this","layer","wrapper_idx",":","int","index","of","this","wrapper","in","pruner","'s","all","wrappers","Returns","--","--","--","-","dict","dictionary","for","storing","masks",",","keys","of","the","dict",":","'weight_mask","'",":","weight","mask","tensor","'bias_mask","'",":","bias","mask","tensor","(","optional",")"]
code: def _normal_calc_mask(self, sparsity, wrapper, wrapper_idx=None):
      """
      Calculate the mask of given layer.
      Parameters
      ----------
      sparsity: float
          pruning ratio,  preserved weight ratio is `1 - sparsity`
      wrapper: PrunerModuleWrapper
          layer wrapper of this layer
      wrapper_idx: int
          index of this wrapper in pruner's all wrappers
      Returns
      -------
      dict
          dictionary for storing masks, keys of the dict:
          'weight_mask':  weight mask tensor
          'bias_mask': bias mask tensor (optional)
      """
      mask, weight, num_prune = self._get_current_state(
          sparsity, wrapper, wrapper_idx
      )
      num_total = weight.size(0)
      if num_total < 2 or num_prune < 1:
          return mask
  
      return self.get_mask(
          mask, weight, num_prune, wrapper, wrapper_idx
      )
  
imports: import logging
  import math
  import numpy
  import torch
  from .weight_masker import WeightMasker
label_desc: Use image node_id 4 for calling the StructuredWeightMasker obj's underlying member method code with example usage: obj._normal_calc_mask(sparsity, wrapper, wrapper_idx) and returns: self, mask