code: def run(input_tflite_path, m_by_n_str):
      """Checks type of sparsity for each layer of the model."""
  
      # convert first 2 value string to a tuple of 2 value
      m_by_n = tuple(map(int, m_by_n_str[:2]))
  
      interpreter = tf.lite.Interpreter(model_path=input_tflite_path)
      interpreter.allocate_tensors()
  
      details = interpreter.get_tensor_details()
      # Don't consider layers that can't be pruned.
      details = [
          x for x in details if not ignore_tensor(x, IGNORE_LIST)
      ]
  
      for detail in details:
          name = detail["name"]
          shape = detail["shape"]
          weights = interpreter.tensor(detail["index"])()
  
          weights_ts = tf.constant(weights)
          pruned_m_by_n = pruning_utils.is_pruned_m_by_n(
              weights_ts, m_by_n, "C_IN"
          )
          sparsity = calculate_sparsity(weights_ts)
  
          print(
              f"{name}: shape: {shape}, sparsity: {sparsity}, "
              f"{m_by_n[0]}_by_{m_by_n[1]} sparsity: {pruned_m_by_n}."
          )
  
file_path: model-optimization/tensorflow_model_optimization/python/core/sparsity/keras/tools/check_sparsity_m_by_n.py
imports: from __future__ import print_function
  from absl import app
  from absl import flags
  import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_utils
label_desc: Use image node_id 3 for calling a global function with example usage: run(input_tflite_path, m_by_n_str) without return types