class_docstr: A cudf based implementation of Stratified K-Folds cross-validator.
  
  Provides train/test indices to split data into stratified K folds.
  The percentage of samples for each class are maintained in each
  fold.
  
  Parameters
  ----------
  n_splits : int, default=5
      Number of folds. Must be at least 2.
  shuffle : boolean, default=False
      Whether to shuffle each class's samples before splitting.
  random_state : int (default=None)
      Random seed
  
  Examples
  --------
  Splitting X,y into stratified K folds
  .. code-block:: python
      import cupy
      X = cupy.random.rand(12,10)
      y = cupy.arange(12)%4
      kf = StratifiedKFold(n_splits=3)
      for tr,te in kf.split(X,y):
          print(tr, te)
  Output:
  .. code-block:: python
      [ 4  5  6  7  8  9 10 11] [0 1 2 3]
      [ 0  1  2  3  8  9 10 11] [4 5 6 7]
      [0 1 2 3 4 5 6 7] [ 8  9 10 11]
code: def split(self, x, y):
      if len(x) != len(y):
          raise ValueError("Expecting same length of x and y")
      y = input_to_cuml_array(y).array.to_output("cupy")
      if len(cp.unique(y)) < 2:
          raise ValueError(
              "number of unique classes cannot be less than 2"
          )
      df = cudf.DataFrame()
      ids = cp.arange(y.shape[0])
  
      if self.shuffle:
          cp.random.seed(self.seed)
          cp.random.shuffle(ids)
          y = y[ids]
  
      df["y"] = y
      df["ids"] = ids
      grpby = df.groupby(["y"])
  
      dg = grpby.agg({"y": "count"})
      col = dg.columns[0]
      msg = (
          f"n_splits={self.n_splits} cannot be greater "
          + "than the number of members in each class."
      )
      if self.n_splits > dg[col].min():
          raise ValueError(msg)
  
      def get_order_in_group(y, ids, order):
          for i in range(cuda.threadIdx.x, len(y), cuda.blockDim.x):
              order[i] = i
  
      got = grpby.apply_grouped(
          get_order_in_group,
          incols=["y", "ids"],
          outcols={"order": "int32"},
          tpb=64,
      )
      got = got.sort_values("ids")
  
      for i in range(self.n_splits):
          mask = got["order"] % self.n_splits == i
          train = got.loc[~mask, "ids"].values
          test = got.loc[mask, "ids"].values
          if len(test) == 0:
              break
          yield train, test
  
file_path: cuml/python/cuml/model_selection/_split.py
imports: from typing import Optional, Union
  from cuml.common import input_to_cuml_array
  from cuml.internals.array import array_to_memory_order
  from cuml.internals.safe_imports import cpu_only_import, gpu_only_import, gpu_only_import_from
label_desc: Use image node_id 3 for calling the StratifiedKFold obj's underlying member method code with example usage: obj.split(x, y) without return types