code: def print_unique_weights(model):
      """Check Dense and Conv2D layers."""
      for layer in model.layers:
          if (
              isinstance(layer, tf.keras.layers.Conv2D)
              or isinstance(layer, tf.keras.layers.Dense)
              or isinstance(
                  layer, quantize.quantize_wrapper.QuantizeWrapper
              )
          ):
              for weights in layer.trainable_weights:
                  np_weights = tf.keras.backend.get_value(weights)
                  unique_weights = len(np.unique(np_weights))
                  if isinstance(
                      layer, quantize.quantize_wrapper.QuantizeWrapper
                  ):
                      print(
                          layer.layer.__class__.__name__,
                          " (",
                          weights.name,
                          ") unique_weights: ",
                          unique_weights,
                      )
                  else:
                      print(
                          layer.__class__.__name__,
                          " (",
                          weights.name,
                          ") unique_weights: ",
                          unique_weights,
                      )
  
file_path: model-optimization/tensorflow_model_optimization/python/examples/cluster_preserve_qat/keras/mnist_cnn.py
imports: from __future__ import print_function
  import os
  from absl import app
  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.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 7 for calling a global function with example usage: print_unique_weights(model) without return types