class_docstr: Weight clustering compression module config.
class_docstr_tok: ["Weight","clustering","compression","module","config","."]
docstr: Model developer API for optimizing a model.
docstr_tok: ["Model","developer","API","for","optimizing","a","model","."]
code: def compress_model(
      self, to_optimize: tf.keras.Model
  ) -> tf.keras.Model:
      """Model developer API for optimizing a model."""
  
      def _optimize_layer(layer):
          # Require layer to be built so that the SVD-factorized weights
          # can be initialized from the weights.
          if not layer.built:
              raise ValueError(
                  "Applying weight clustering currently "
                  "requires passing in a built model"
              )
  
          return algorithm.create_layer_for_training(
              layer, algorithm=self
          )
  
      return tf.keras.models.clone_model(
          to_optimize, clone_function=_optimize_layer
      )
  
file_path: model-optimization/tensorflow_model_optimization/python/core/common/keras/compression/algorithms/weight_clustering.py
imports: from typing import List
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras import clustering_centroids
  from tensorflow_model_optimization.python.core.clustering.keras import clustering_registry
  from tensorflow_model_optimization.python.core.clustering.keras.cluster_config import GradientAggregation
  from tensorflow_model_optimization.python.core.common.keras.compression import algorithm
label_desc: Use image node_id 6 for calling the WeightClustering obj's underlying member method code with example usage: obj.compress_model(to_optimize) and returns: tf, algorithm