code: def run(input_model_path, output_dir, target_sparsity, block_size):
      """Prunes the model and converts both pruned and unpruned versions to TFLite."""
  
      print(
          textwrap.dedent(
              """\
      Warning: The sparse models produced by this tool have poor accuracy. They
               are not intended to be served in production, but to be used for
               performance benchmarking."""
          )
      )
  
      input_model = tf.keras.models.load_model(input_model_path)
  
      os.makedirs(output_dir, exist_ok=True)
      unpruned_tflite_path = os.path.join(
          output_dir, "unpruned_model.tflite"
      )
      pruned_tflite_path = os.path.join(
          output_dir, pruned_model_filename(target_sparsity, block_size)
      )
  
      # Convert to TFLite without pruning
      convert_to_tflite(input_model, unpruned_tflite_path)
  
      # Prune and convert to TFLite
      pruned_model = sparsity_tooling.prune_for_benchmark(
          keras_model=input_model,
          target_sparsity=target_sparsity,
          block_size=block_size,
      )
      stripped_model = prune.strip_pruning(
          pruned_model
      )  # Remove pruning wrapper
      convert_to_tflite(stripped_model, pruned_tflite_path)
  
      # Measure the compressed size of unpruned vs pruned TFLite models
      unpruned_compressed_size = get_gzipped_size(unpruned_tflite_path)
      pruned_compressed_size = get_gzipped_size(pruned_tflite_path)
      print("Size of gzipped TFLite models:")
      print(
          " * Unpruned : %.2fMiB"
          % (unpruned_compressed_size / (2.0**20))
      )
      print(
          " * Pruned   : %.2fMiB"
          % (pruned_compressed_size / (2.0**20))
      )
      print(
          "       diff : %d%%"
          % (
              100.0
              * (pruned_compressed_size - unpruned_compressed_size)
              / unpruned_compressed_size
          )
      )
  
file_path: model-optimization/tensorflow_model_optimization/python/core/sparsity/keras/tools/evaluate_pruning.py
imports: from __future__ import print_function
  import os
  import tempfile
  import textwrap
  import zipfile
  from absl import app
  from absl import flags
  import tensorflow
  from tensorflow_model_optimization.python.core.sparsity.keras import prune
  from tensorflow_model_optimization.python.core.sparsity.keras.tools import sparsity_tooling
label_desc: Use image node_id 6 for calling a global function with example usage: run(input_model_path, output_dir, target_sparsity, block_size) without return types