code: def testWeightClustering_SingleLayer(self):
      number_of_clusters = 8
      i = tf.keras.layers.Input(shape=(2), name="input")
      output = tf.keras.layers.Dense(3, name="fc1")(i)
      model = tf.keras.Model(inputs=[i], outputs=[output])
  
      dense_layer_weights = model.layers[1].get_weights()
  
      algorithm = weight_clustering.WeightClustering(
          number_of_clusters=number_of_clusters,
          cluster_centroids_init=cluster_config.CentroidInitialization.DENSITY_BASED,
      )
      compressed_model = algorithm.compress_model(model)
  
      dense_layer_compressed_weights = compressed_model.layers[
          1
      ].get_weights()
  
      # clustering_centroids.
      self.assertEqual(
          dense_layer_compressed_weights[0].shape, (number_of_clusters,)
      )
  
      # pulling_indices.
      self.assertEqual(
          dense_layer_compressed_weights[1].shape,
          dense_layer_weights[0].shape,
      )
      self.assertEqual(
          str(dense_layer_compressed_weights[1].dtype), "int64"
      )
      self.assertAllInRange(
          dense_layer_compressed_weights[1], 0, number_of_clusters - 1
      )
  
      # bias
      assert (
          dense_layer_weights[1] == dense_layer_compressed_weights[2]
      ).all()
  
file_path: model-optimization/tensorflow_model_optimization/python/core/common/keras/compression/algorithms/weight_clustering_test.py
imports: import os
  import tempfile
  import zipfile
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras import cluster_config
  from tensorflow_model_optimization.python.core.common.keras.compression.algorithms import weight_clustering
label_desc: Use image node_id 2 for calling the FunctionalTest obj's underlying member method code with example usage: obj.testWeightClustering_SingleLayer() without return types