code: def segment_by_class(
      data: Union[np.ndarray, List[int]],
      classes: np.ndarray,
      num_classes: int,
  ) -> List[np.ndarray]:
      """
      Returns segmented data according to specified features.
  
      :param data: Data to be segmented.
      :param classes: Classes used to segment data, e.g., segment according to predicted label or to `y_train` or other
                      array of one hot encodings the same length as data.
      :param num_classes: How many features.
      :return: Segmented data according to specified features.
      """
      by_class: List[List[int]] = [[] for _ in range(num_classes)]
      for indx, feature in enumerate(classes):
          if len(classes.shape) == 2 and classes.shape[1] > 1:
              assigned = int(np.argmax(feature))
          else:
              assigned = int(feature)
          by_class[assigned].append(data[indx])
  
      return [np.asarray(i) for i in by_class]
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import math
  import os
  import shutil
  import sys
  import tarfile
  import warnings
  import zipfile
  from functools import wraps
  from inspect import signature
  from typing import TYPE_CHECKING, Callable, List, Dict, Optional, Tuple, Union
  import numpy
  import six
  from scipy.special import gammainc
  from tqdm.auto import tqdm
  from art import config
label_desc: Use image node_id 40 for calling a global function with example usage: segment_by_class(data, classes, num_classes) and returns: unknown