class_docstr: Integration test for cluster_per_channel for Conv2D layer.
code: def testPerChannel(self):
      model = self._get_model()
  
      clustered_model = cluster.cluster_weights(
          model, **self.params_clustering
      )
  
      clustered_model.compile(
          optimizer=tf.keras.optimizers.Adam(learning_rate=1e-4),
          loss=tf.keras.losses.SparseCategoricalCrossentropy(
              from_logits=True
          ),
          metrics=[
              tf.keras.metrics.SparseCategoricalAccuracy(
                  name="accuracy"
              )
          ],
      )
      clustered_model.fit(
          self.x_train,
          self.y_train,
          epochs=2,
          batch_size=100,
          verbose=1,
      )
  
      stripped_model = cluster.strip_clustering(clustered_model)
  
      layer_conv2d = stripped_model.layers[2]
      layer_conv2d_kernel_weight = None
      for weight in layer_conv2d.weights:
          if "kernel" in weight.name:
              layer_conv2d_kernel_weight = weight
      self.assertIsNotNone(layer_conv2d_kernel_weight)
      nr_unique_weights = len(
          np.unique(layer_conv2d_kernel_weight.numpy())
      )
      self.assertEqual(
          nr_unique_weights, self.nr_of_clusters * self.num_channels
      )
  
      # The above check is too general.
      # We need to check that we actually have nr_of_clusters per channel.
      # If more general case passed, then we do tighter check.
      # Note that we assume that data_format is NHWC.
      for i in range(self.num_channels):
          nr_unique_weights_per_channel = len(
              np.unique(layer_conv2d_kernel_weight[:, :, :, i])
          )
          self.assertEqual(
              nr_unique_weights_per_channel, self.nr_of_clusters
          )
  
imports: import os
  import tempfile
  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
label_desc: Use image node_id 3 for calling the ClusterPerChannelIntegrationTest obj's underlying member method code with example usage: obj.testPerChannel() without return types