docstr: Returns clustered per channel model with Conv2D layer.
docstr_tok: ["Returns","clustered","per","channel","model","with","Conv2D","layer","."]
code: def _get_conv_clustered_model(
      self,
      nr_of_channels,
      nr_of_clusters,
      data_format,
      preserve_sparsity,
      kernel_size=(3, 3),
  ):
      """Returns clustered per channel model with Conv2D layer."""
      tf.random.set_seed(42)
      model = self._get_conv_model(
          nr_of_channels, data_format, kernel_size
      )
  
      if preserve_sparsity:
          # Make the convolutional layer sparse by nullifying half of weights
          assert model.layers[2].name == "conv2d"
  
          conv_layer_weights = model.layers[2].get_weights()
          shape = conv_layer_weights[0].shape
          conv_layer_weights_flatten = conv_layer_weights[0].flatten()
  
          nr_elems = len(conv_layer_weights_flatten)
          conv_layer_weights_flatten[0 : 1 + nr_elems // 2] = 0.0
          pruned_conv_layer_weights = tf.reshape(
              conv_layer_weights_flatten, shape
          )
          conv_layer_weights[0] = pruned_conv_layer_weights
          model.layers[2].set_weights(conv_layer_weights)
  
      clustering_params = {
          "number_of_clusters": nr_of_clusters,
          "cluster_centroids_init": cluster_config.CentroidInitialization.KMEANS_PLUS_PLUS,
          "cluster_per_channel": True,
          "preserve_sparsity": preserve_sparsity,
      }
  
      clustered_model = experimental_cluster.cluster_weights(
          model, **clustering_params
      )
      clustered_model = self._compile_and_fit_conv_model(
          clustered_model
      )
  
      # Returns un-stripped model
      return clustered_model
  
imports: 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.experimental import cluster
  from tensorflow_model_optimization.python.core.quantization.keras import quantize
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.cluster_preserve import default_8bit_cluster_preserve_quantize_scheme
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.cluster_preserve.cluster_utils import strip_clustering_cqat
label_desc: Use image node_id 8 for calling the ClusterPreserveIntegrationTest obj's underlying member method code with example usage: obj._get_conv_clustered_model(nr_of_channels, nr_of_clusters, data_format, preserve_sparsity, kernel_size) and returns: clustered_model