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 masks for the layers in the same dependency sets.
  Similar to the traditional original calc_mask, _dependency_calc_mask
  will prune the target layers based on the L1/L2 norm of the weights.
  However, StructuredWeightMasker prunes the filter completely based on the
  L1/L2 norm of each filter. In contrast, _dependency_calc_mask
  will try to satisfy the channel/group dependency(see nni.compression.torch.
  utils.shape_dependency for details). Specifically, _dependency_calc_mask
  will try to prune the same channels for the layers that have channel dependency.
  In addition, this mask calculator will also ensure that the number of filters
  pruned in each group is the same(meet the group dependency).
  
  Parameters
  ----------
  sparsities : list
      List of float that specify the sparsity for each conv layer.
  wrappers : list
      List of wrappers
  groups : list
      The number of the filter groups of each layer.
  wrappers_idx : list
      The indexes of the wrappers
docstr_tok: ["Calculate","the","masks","for","the","layers","in","the","same","dependency","sets",".","Similar","to","the","traditional","original","calc_mask",",","_dependency_calc_mask","will","prune","the","target","layers","based","on","the","L1\/L2","norm","of","the","weights",".","However",",","StructuredWeightMasker","prunes","the","filter","completely","based","on","the","L1\/L2","norm","of","each","filter",".","In","contrast",",","_dependency_calc_mask","will","try","to","satisfy","the","channel\/group","dependency","(","see","nni.compression.torch",".","utils.shape_dependency","for","details",")",".","Specifically",",","_dependency_calc_mask","will","try","to","prune","the","same","channels","for","the","layers","that","have","channel","dependency",".","In","addition",",","this","mask","calculator","will","also","ensure","that","the","number","of","filters","pruned","in","each","group","is","the","same","(","meet","the","group","dependency",")",".","Parameters","--","--","--","--","--","sparsities",":","list","List","of","float","that","specify","the","sparsity","for","each","conv","layer",".","wrappers",":","list","List","of","wrappers","groups",":","list","The","number","of","the","filter","groups","of","each","layer",".","wrappers_idx",":","list","The","indexes","of","the","wrappers"]
code: def _dependency_calc_mask(
      self, sparsities, wrappers, wrappers_idx, channel_dsets, groups
  ):
      """
      Calculate the masks for the layers in the same dependency sets.
      Similar to the traditional original calc_mask, _dependency_calc_mask
      will prune the target layers based on the L1/L2 norm of the weights.
      However, StructuredWeightMasker prunes the filter completely based on the
      L1/L2 norm of each filter. In contrast, _dependency_calc_mask
      will try to satisfy the channel/group dependency(see nni.compression.torch.
      utils.shape_dependency for details). Specifically, _dependency_calc_mask
      will try to prune the same channels for the layers that have channel dependency.
      In addition, this mask calculator will also ensure that the number of filters
      pruned in each group is the same(meet the group dependency).
  
      Parameters
      ----------
      sparsities : list
          List of float that specify the sparsity for each conv layer.
      wrappers : list
          List of wrappers
      groups : list
          The number of the filter groups of each layer.
      wrappers_idx : list
          The indexes of the wrappers
      """
      channel_masks = self._common_channel_to_prune(
          sparsities, wrappers, wrappers_idx, channel_dsets, groups
      )
      # calculate the mask for each layer based on channel_masks, first
      # every layer will prune the same channels masked in channel_masks.
      # If the sparsity of a layers is larger than min_sparsity, then it
      # will continue prune sparsity - min_sparsity channels to meet the sparsity
      # config.
      masks = {}
      for _pos, _w in enumerate(wrappers):
          _w_idx = wrappers_idx[_pos]
          sparsity = sparsities[_pos]
          name = _w.name
  
          # _tmp_mask = self._normal_calc_mask(
          #     sparsity, _w, _w_idx, channel_masks)
          (
              base_mask,
              current_weight,
              num_prune,
          ) = self._get_current_state(sparsity, _w, _w_idx)
          num_total = current_weight.size(0)
          if num_total < 2 or num_prune < 1:
              masks[name] = base_mask
              continue
          _tmp_mask = self.get_mask(
              base_mask,
              current_weight,
              num_prune,
              _w,
              _w_idx,
              channel_masks,
          )
  
          if _tmp_mask is None:
              # if the mask calculation fails
              return None
          masks[name] = _tmp_mask
      return masks
  
imports: import logging
  import math
  import numpy
  import torch
  from .weight_masker import WeightMasker
label_desc: Use image node_id 6 for calling the StructuredWeightMasker obj's underlying member method code with example usage: obj._dependency_calc_mask(sparsities, wrappers, wrappers_idx, channel_dsets, groups) and returns: masks, None