code: def _gen_batches(n, batch_size, min_batch_size=0):
      """
      Generator to create slices containing batch_size elements, from 0 to n.
      The last slice may contain less than batch_size elements, when batch_size
      does not divide n.
  
      Parameters
      ----------
  
      n : int
      batch_size : int
          Number of element in each batch
      min_batch_size : int, default=0
          Minimum batch size to produce.
  
      Yields
      ------
  
      slice of batch_size elements
  
      """
  
      if not isinstance(batch_size, numbers.Integral):
          raise TypeError(
              "gen_batches got batch_size=%s, must be an"
              " integer" % batch_size
          )
      if batch_size <= 0:
          raise ValueError(
              "gen_batches got batch_size=%s, must be"
              " positive" % batch_size
          )
      start = 0
      for _ in range(int(n // batch_size)):
          end = start + batch_size
          if end + min_batch_size > n:
              continue
          yield slice(start, end)
          start = end
      if start < n:
          yield slice(start, n)
  
imports: from cuml.decomposition import PCA
  from cuml.internals.array import CumlArray
  import cuml.internals
  from cuml.internals.input_utils import input_to_cupy_array
  from cuml.common import input_to_cuml_array
  from cuml import Base
  from cuml.internals.safe_imports import cpu_only_import
  import numbers
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 2 for calling a global function with example usage: _gen_batches(n, batch_size, min_batch_size) without return types