class_docstr: Distributed tests for clustering.
docstr: End-to-end test.
docstr_tok: ["End-to-end","test","."]
code: def testClusterSimpleDenseModel(self, distribution, clustering):
      """End-to-end test."""
      with distribution.scope():
          model = experimental_cluster.cluster_weights(
              keras_test_utils.build_simple_dense_model(), **clustering
          )
          model.compile(
              loss="categorical_crossentropy",
              optimizer="sgd",
              metrics=["accuracy"],
          )
  
      model.summary()
      model.fit(
          np.random.rand(20, 10),
          keras.utils.to_categorical(
              np.random.randint(5, size=(20, 1)), 5
          ),
          epochs=1,
          batch_size=20,
      )
      model.predict(np.random.rand(20, 10))
  
      stripped_model = cluster.strip_clustering(model)
      weights_as_list = (
          stripped_model.layers[0]
          .kernel.numpy()
          .reshape(
              -1,
          )
          .tolist()
      )
      unique_weights = set(weights_as_list)
      self.assertLessEqual(
          len(unique_weights), clustering["number_of_clusters"]
      )
  
file_path: model-optimization/tensorflow_model_optimization/python/core/clustering/keras/cluster_distributed_test.py
imports: import itertools
  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 import cluster_wrapper
  from tensorflow_model_optimization.python.core.clustering.keras.experimental import cluster
  from tensorflow_model_optimization.python.core.keras import test_utils
label_desc: Use image node_id 1 for calling the ClusterDistributedTest obj's underlying member method code with example usage: obj.testClusterSimpleDenseModel(distribution, clustering) without return types