code: def _check_classes(which_classes, n_classes):
      """
      Make sure classes list is valid.
  
      Parameters
      ----------
      which_classes : list, optional
          List of class indices to check. Defaults to None.
      n_classes : int
          Total number of classes.
  
      Returns
      -------
      list
          List of valid class indices.
  
      Raises
      ------
      ValueError
          If class index is less than 0 or greater than or equal to the number of classes.
      """
      if which_classes is None or len(which_classes) == 0:
          which_classes = list(np.arange(n_classes))
      else:
          if n_classes > 0:
              if np.min(which_classes) < 0:
                  raise ValueError("class index should be >= 0.")
              if np.max(which_classes) > n_classes - 1:
                  raise ValueError("class index should be < n_classes.")
      if n_classes <= 2:
          which_classes = [0]
      return which_classes
  
imports: import numpy
  import pandas
  import psutil
label_desc: Use image node_id 7 for calling a global function with example usage: _check_classes(which_classes, n_classes) and returns: which_classes