code: def is_pruned_m_by_n(
      weights, m_by_n=(2, 4), last_channel: str = "C_OUT"
  ):
      """Check m by n sparsity pattern on Weight Tensor.
  
      This is a m_by_n sparsity helper function.
  
      Args:
        weights: A tensor of layer weights.
        m_by_n: a tuple of 2 integers (m, n), indicates m zeros in every n
          consecutive values, m must be smaller than n. Default to (2, 4).
        last_channel: A string, 'C_OUT'(default) and 'C_IN' are supported.  Last
          channel of weights tensor.
            Conv2D weights in TF: [H, W, C_IN, C_OUT], TFLite: [C_OUT, H, W, C_IN]
            DENSE weights in TF: [C_IN, C_OUT], TFLite: [C_OUT, C_IN]
  
      Returns:
        A boolean value: True if weights are pruned with sparsity m_by_n
          on the last channel.
  
      Raises:
        ValueError:
          if unsupported last_channel.
          if m is larger than n.
  
      """
      num_zeros, num_elem = m_by_n
      if num_zeros > num_elem:
          raise ValueError(
              f"number of zeros can't be more than number elements. "
              f"received: {num_zeros} zeros in {num_elem} elements."
          )
      num_non_zeros = num_elem - num_zeros
  
      if last_channel.endswith("C_IN"):
          prepared_weights = tf.reshape(
              weights, [tf.reduce_prod(weights.shape[:-1]), -1]
          )
      elif last_channel.endswith("C_OUT"):
          prepared_weights = weights_rearrange(weights)
      else:
          raise ValueError("last_channel must be `C_IN` or `C_OUT`")
  
      prepared_weights_np = prepared_weights.numpy()
      for row in range(0, prepared_weights_np.shape[0]):
          for col in range(0, prepared_weights_np.shape[1], num_elem):
              if (
                  np.count_nonzero(
                      prepared_weights_np[row, col : col + num_elem]
                  )
                  > num_non_zeros
              ):
                  return False
      return True
  
file_path: model-optimization/tensorflow_model_optimization/python/core/sparsity/keras/pruning_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
label_desc: Use image node_id 8 for calling a global function with example usage: is_pruned_m_by_n(weights, m_by_n, last_channel) and returns: True, False