code: def _get_sparsity(self, model):
      sparsity_list = []
      for layer in model.layers:
          for weights in layer.trainable_weights:
              if "kernel" in weights.name:
                  np_weights = tf.keras.backend.get_value(weights)
                  sparsity = 1.0 - np.count_nonzero(np_weights) / float(
                      np_weights.size
                  )
                  sparsity_list.append(sparsity)
  
      return sparsity_list
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras import cluster
  from tensorflow_model_optimization.python.core.clustering.keras import cluster_config
  from tensorflow_model_optimization.python.core.clustering.keras.experimental import cluster
  from tensorflow_model_optimization.python.core.quantization.keras import quantize
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.cluster_preserve import default_8bit_cluster_preserve_quantize_scheme
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.cluster_preserve.cluster_utils import strip_clustering_cqat
label_desc: Use image node_id 4 for calling the ClusterPreserveIntegrationTest obj's underlying member method code with example usage: obj._get_sparsity(model) and returns: sparsity_list