code: def test_output_clusters(self):
      # Get MNIST
      (x_train, _), (_, _), (_, _) = self.mnist
  
      n_classes = self.classifier.nb_classes
      for nb_clusters in range(2, 5):
          clusters_by_class, _ = self.defence.cluster_activations(
              nb_clusters=nb_clusters
          )
  
          # Verify expected number of classes
          self.assertEqual(len(clusters_by_class), n_classes)
          # Check we get the expected number of clusters:
          found_clusters = len(np.unique(clusters_by_class[0]))
          self.assertEqual(found_clusters, nb_clusters)
          # Check right amount of data
          n_dp = 0
          for i in range(0, n_classes):
              n_dp += len(clusters_by_class[i])
          self.assertEqual(len(x_train), n_dp)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  from keras.preprocessing.image import ImageDataGenerator
  import numpy
  from art.data_generators import KerasDataGenerator
  from art.defences.detector.poison import ActivationDefence
  from art.utils import load_mnist
  from art.visualization import convert_to_rgb
  from tests.utils import master_seed
label_desc: Use image node_id 9 for calling the TestActivationDefence obj's underlying member method code with example usage: obj.test_output_clusters() without return types