class_docstr: Unit tests for clustering lookup algorithms.
class_docstr_tok: ["Unit","tests","for","clustering","lookup","algorithms","."]
docstr: Verifies that the gradients of DenseWeightsCA work as expected.
docstr_tok: ["Verifies","that","the","gradients","of","DenseWeightsCA","work","as","expected","."]
code: def testDenseWeightsCAGrad(
      self,
      cluster_gradient_aggregation,
      pulling_indices,
      expected_grad_centroids,
  ):
      """Verifies that the gradients of DenseWeightsCA work as expected."""
      clustering_centroids = tf.Variable([-0.800450444, 0.864694357])
      weight = tf.constant(
          [
              [0.220442653, 0.854694366, 0.0328432359, 0.506857157],
              [0.0527950861, -0.659555554, -0.849919915, -0.54047],
              [-0.305815876, 0.0865516588, 0.659202456, -0.355699599],
              [-0.348868281, -0.662001, 0.6171574, -0.296582848],
          ]
      )
  
      clustering_algo = clustering_registry.ClusteringAlgorithm(
          clustering_centroids, cluster_gradient_aggregation
      )
  
      self._check_gradients_clustered_weight(
          clustering_algo,
          weight,
          pulling_indices,
          expected_grad_centroids,
      )
  
imports: from absl.testing import parameterized
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras import clusterable_layer
  from tensorflow_model_optimization.python.core.clustering.keras import clustering_registry
  from tensorflow_model_optimization.python.core.clustering.keras.cluster_config import GradientAggregation
label_desc: Use image node_id 3 for calling the ClusteringAlgorithmTest obj's underlying member method code with example usage: obj.testDenseWeightsCAGrad(cluster_gradient_aggregation, pulling_indices, expected_grad_centroids) without return types