code: def test_segment_by_class(self):
      data = np.array([[3, 2], [9, 2], [4, 0], [9, 0]])
      classes = to_categorical(np.array([2, 1, 0, 1]))
      num_classes = 3
      segments = segment_by_class(data, classes, num_classes)
      self.assertEqual(len(segments), num_classes)
      self.assertEqual(len(segments[1]), 2)
      self.assertTrue(
          np.all(np.equal(segments[0], np.array([data[2]])))
      )
      self.assertTrue(
          np.all(np.equal(segments[1], np.array([data[1], data[3]])))
      )
      self.assertTrue(
          np.all(np.equal(segments[2], np.array([data[0]])))
      )
  
      num_classes = 4
      segments = segment_by_class(data, classes, num_classes)
      self.assertEqual(len(segments), num_classes)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  import tensorflow
  from art.utils import projection, random_sphere, uniform_sample_from_sphere_or_ball, to_categorical, least_likely_class
  from art.utils import load_dataset, load_iris, load_mnist, load_nursery, load_cifar10
  from art.utils import second_most_likely_class, random_targets, get_label_conf, get_labels_np_array, preprocess
  from art.utils import compute_success_array, compute_success, check_and_transform_label_format
  from art.utils import segment_by_class, performance_diff
  from art.utils import is_probability
  from tests.utils import master_seed
label_desc: Use image node_id 24 for calling the TestUtils obj's underlying member method code with example usage: obj.test_segment_by_class() without return types