class_docstr: Prune model to an exact pruning level for one time.
class_docstr_tok: ["Prune","model","to","an","exact","pruning","level","for","one","time","."]
docstr: Calculate the mask of given layer
  Parameters
  ----------
  wrapper : Module
      the module to instrument the compression operation
  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 calc_mask(self, wrapper, wrapper_idx=None):
      """
      Calculate the mask of given layer
      Parameters
      ----------
      wrapper : Module
          the module to instrument the compression operation
      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)
      """
      if wrapper.if_calculated:
          return None
  
      sparsity = wrapper.config["sparsity"]
      if not wrapper.if_calculated:
          masks = self.masker.calc_mask(
              sparsity=sparsity,
              wrapper=wrapper,
              wrapper_idx=wrapper_idx,
          )
  
          # masker.calc_mask returns None means calc_mask is not calculated sucessfully, can try later
          if masks is not None:
              wrapper.if_calculated = True
          return masks
      else:
          return None
  
imports: import logging
  from schema import And, Optional, SchemaError
  from .._graph_utils import TorchModuleGraph
  from ..utils.shape_dependency import ChannelDependency, GroupDependency
  from .constants import MASKER_DICT
  from ..utils.config_validation import CompressorSchema
  from ..compressor import Pruner
label_desc: Use image node_id 3 for calling the OneshotPruner obj's underlying member method code with example usage: obj.calc_mask(wrapper, wrapper_idx) and returns: None, masks, None