code: def _check_sparsity_kernel(model):
      sparsity_list = []
      for layer in model.layers:
          if isinstance(
              layer,
              (
                  prune.pruning_wrapper.PruneLowMagnitude,
                  quantize.quantize_wrapper.QuantizeWrapper,
              ),
          ):
              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: 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 cluster_utils
  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.sparsity.keras import prune
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_callbacks
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_schedule
label_desc: Use image node_id 10 for calling a global function with example usage: _check_sparsity_kernel(model) and returns: sparsity_list