code: def strip_clustering(model):
      """Strips clustering wrappers from the model.
  
      Once a model has been clustered, this method can be used
      to restore the original model with the clustered weights.
  
      Only sequential and functional models are supported for now.
  
      Arguments:
          model: A `tf.keras.Model` instance with clustered layers.
  
      Returns:
        A keras model with clustering wrappers removed.
  
      Raises:
        ValueError: if the model is not a `tf.keras.Model` instance.
        NotImplementedError: if the model is a subclass model.
  
      Usage:
  
      ```python
      orig_model = tf.keras.Model(inputs, outputs)
      clustered_model = cluster_weights(orig_model)
      exported_model = strip_clustering(clustered_model)
      ```
      The exported_model and the orig_model have the same structure.
      """
      if not isinstance(model, tf.keras.Model):
          raise ValueError(
              "Expected model to be a `tf.keras.Model` instance but got: ",
              model,
          )
  
      def _strip_clustering_wrapper(layer):
          if isinstance(layer, tf.keras.Model):
              return tf.keras.models.clone_model(
                  layer,
                  input_tensors=None,
                  clone_function=_strip_clustering_wrapper,
              )
  
          elif isinstance(layer, cluster_wrapper.ClusterWeightsMHA):
              # Update cluster associations in order to get the latest weights
              layer.update_clustered_weights_associations()
  
              # In case of MHA layer, use the overloaded implementation
              return layer.strip_clustering()
  
          elif isinstance(layer, cluster_wrapper.ClusterWeights):
              # Update cluster associations in order to get the latest weights
              layer.update_clustered_weights_associations()
  
              # Construct a list of weights to initialize the clean layer
              # non-clusterable weights only
              updated_weights = layer.layer.get_weights()
              for (
                  position_variable,
                  weight_name,
              ) in layer.position_original_weights.items():
                  # Add the clustered weights at the correct position
                  clustered_weight = layer.get_weight_from_layer(
                      weight_name
                  )
                  updated_weights.insert(
                      position_variable, clustered_weight
                  )
  
              # Construct a clean layer with the updated weights
              clean_layer = layer.layer.from_config(
                  layer.layer.get_config()
              )
              clean_layer.build(layer.build_input_shape)
              clean_layer.set_weights(updated_weights)
  
              return clean_layer
  
          return layer
  
      # Just copy the model with the right callback
      return tf.keras.models.clone_model(
          model,
          input_tensors=None,
          clone_function=_strip_clustering_wrapper,
      )
  
file_path: model-optimization/tensorflow_model_optimization/python/core/clustering/keras/cluster.py
imports: import warnings
  import tensorflow
  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 import clustering_centroids
label_desc: Use image node_id 4 for calling a global function with example usage: strip_clustering(model) and returns: tf, layer, tf, layer, clean_layer