class_docstr: Implementation of magnitude-based weight pruning.
class_docstr_tok: ["Implementation","of","magnitude-based","weight","pruning","."]
docstr: Updates the m by n sparsity mask for a given weight tensor.
  
  This function creates a mask for the given weight tensor so
  that n elements with the lowest absolute values in the block
  of m elements are set to be zero. We don't return any threshold.
  
  Args:
    weights: The weight tensor that needs to be masked.
    m_by_n: tuple of two integers, indicating m zeros out of n consecutive
      elements, default as 2 by 4 sparsity.
  
  Returns:
    new_mask: A numpy array of the same size and shape as weights containing
    0 or 1 to indicate which of the values in weights should be set to zero.
    It throws an error if the requested mask cannot be created.
docstr_tok: ["Updates","the","m","by","n","sparsity","mask","for","a","given","weight","tensor",".","This","function","creates","a","mask","for","the","given","weight","tensor","so","that","n","elements","with","the","lowest","absolute","values","in","the","block","of","m","elements","are","set","to","be","zero",".","We","do","n't","return","any","threshold",".","Args",":","weights",":","The","weight","tensor","that","needs","to","be","masked",".","m_by_n",":","tuple","of","two","integers",",","indicating","m","zeros","out","of","n","consecutive","elements",",","default","as","2","by","4","sparsity",".","Returns",":","new_mask",":","A","numpy","array","of","the","same","size","and","shape","as","weights","containing","0","or","1","to","indicate","which","of","the","values","in","weights","should","be","set","to","zero",".","It","throws","an","error","if","the","requested","mask","can","not","be","created","."]
code: def _update_mask_sparsity_m_by_n(self, weights, m_by_n=(2, 4)):
      """Updates the m by n sparsity mask for a given weight tensor.
  
      This function creates a mask for the given weight tensor so
      that n elements with the lowest absolute values in the block
      of m elements are set to be zero. We don't return any threshold.
  
      Args:
        weights: The weight tensor that needs to be masked.
        m_by_n: tuple of two integers, indicating m zeros out of n consecutive
          elements, default as 2 by 4 sparsity.
  
      Returns:
        new_mask: A numpy array of the same size and shape as weights containing
        0 or 1 to indicate which of the values in weights should be set to zero.
        It throws an error if the requested mask cannot be created.
      """
      prepared_weights = pruning_utils.weights_rearrange(weights)
      mask = pruning_utils.generate_m_by_n_mask(
          prepared_weights, m_by_n
      )
      new_mask = pruning_utils.m_by_n_sparsity_mask_prepare(
          mask, weights.shape
      )
  
      return new_mask
  
file_path: model-optimization/tensorflow_model_optimization/python/core/sparsity/keras/pruning_impl.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tensorflow_model_optimization.python.core.keras import compat
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_utils
label_desc: Use image node_id 4 for calling the Pruning obj's underlying member method code with example usage: obj._update_mask_sparsity_m_by_n(weights, m_by_n) and returns: new_mask