class_docstr: Stratified K-Folds cross-validator that ensures that there is always at least
  1 sample per class in the training set.
code: def _make_test_folds(self, X, y=None):  # type: ignore
      rng = check_random_state(self.random_state)
      y = np.asarray(y)
      type_of_target_y = type_of_target(y)
      allowed_target_types = ("binary", "multiclass")
      if type_of_target_y not in allowed_target_types:
          raise ValueError(
              "Supported target types are: {}. Got {!r} instead.".format(
                  allowed_target_types, type_of_target_y
              )
          )
  
      y = column_or_1d(y)
  
      _, y_idx, y_inv = np.unique(
          y, return_index=True, return_inverse=True
      )
      # y_inv encodes y according to lexicographic order. We invert y_idx to
      # map the classes so that they are encoded by order of appearance:
      # 0 represents the first label appearing in y, 1 the second, etc.
      _, class_perm = np.unique(y_idx, return_inverse=True)
      y_encoded = class_perm[y_inv]
  
      n_classes = len(y_idx)
  
      # Determine the optimal number of samples from each class in each fold,
      # using round robin over the sorted y. (This can be done direct from
      # counts, but that code is unreadable.)
      y_order = np.sort(y_encoded)
      allocation = np.asarray(
          [
              np.bincount(
                  y_order[i :: self.n_splits], minlength=n_classes
              )
              for i in range(self.n_splits)
          ]
      )
  
      # To maintain the data order dependencies as best as possible within
      # the stratification constraint, we assign samples from each class in
      # blocks (and then mess that up when shuffle=True).
      test_folds = np.empty(len(y), dtype="i")
      for k in range(n_classes):
          # since the kth column of allocation stores the number of samples
          # of class k in each test set, this generates blocks of fold
          # indices corresponding to the allocation for class k.
          folds_for_class = np.arange(self.n_splits).repeat(
              allocation[:, k]
          )
          if self.shuffle:
              rng.shuffle(folds_for_class)
          test_folds[y_encoded == k] = folds_for_class
      return test_folds
  
file_path: auto-sklearn/autosklearn/evaluation/splitter.py
imports: import warnings
  import numpy
  from sklearn.model_selection import StratifiedKFold, StratifiedShuffleSplit
  from sklearn.model_selection._split import _validate_shuffle_split
  from sklearn.utils import _approximate_mode, check_random_state, indexable
  from sklearn.utils.multiclass import type_of_target
  from sklearn.utils.validation import _num_samples, check_array, column_or_1d
label_desc: Use image node_id 1 for calling the CustomStratifiedKFold obj's underlying member method code with example usage: obj._make_test_folds(X, y) and returns: test_folds