docstr: Checks that models are recursively pruned.
docstr_tok: ["Checks","that","models","are","recursively","pruned","."]
code: def test_prune_model_recursively(self):
      """Checks that models are recursively pruned."""
  
      # Setup a model with one layer being a keras.Model.
      internal_model = keras.Sequential(
          [
              keras.layers.Dense(10, input_shape=(10,)),
          ]
      )
      model = keras.Sequential(
          [
              internal_model,
              keras.layers.Dense(20),
          ]
      )
      pruned_model = sparsity_tooling.prune_for_benchmark(
          model, target_sparsity=0.8, block_size=(1, 1)
      )
  
      test_utils.assert_model_sparsity(self, 0.8, pruned_model)
  
      # Check the block size of the prunned layers
      prunned_dense_layers = [
          layer
          for layer in pruned_model.submodules
          if isinstance(layer, pruning_wrapper.PruneLowMagnitude)
      ]
      self.assertEqual(2, len(prunned_dense_layers))
      for layer in prunned_dense_layers:
          self.assertEqual((1, 1), layer.block_size)
  
file_path: model-optimization/tensorflow_model_optimization/python/core/sparsity/keras/tools/sparsity_tooling_test.py
imports: import tensorflow
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_wrapper
  from tensorflow_model_optimization.python.core.sparsity.keras import test_utils
  from tensorflow_model_optimization.python.core.sparsity.keras.tools import sparsity_tooling
label_desc: Use image node_id 2 for calling the SparsityToolingTest obj's underlying member method code with example usage: obj.test_prune_model_recursively() without return types