code: def gen_batches(n, batch_size):
      """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.
  
      Examples
      --------
      >>> from sklearn.utils import gen_batches
      >>> list(gen_batches(7, 3))
      [slice(0, 3, None), slice(3, 6, None), slice(6, 7, None)]
      >>> list(gen_batches(6, 3))
      [slice(0, 3, None), slice(3, 6, None)]
      >>> list(gen_batches(2, 3))
      [slice(0, 2, None)]
      """
      start = 0
      for _ in range(int(n // batch_size)):
          end = start + batch_size
          yield slice(start, end)
          start = end
      if start < n:
          yield slice(start, n)
  
imports: from collections import Sequence
  import numpy
  from scipy.sparse import issparse
  import warnings
  from .murmurhash import murmurhash3_32
  from .validation import as_float_array, assert_all_finite, check_random_state, column_or_1d, check_array, check_consistent_length, check_X_y, indexable, check_symmetric
  from .deprecation import deprecated
  from .class_weight import compute_class_weight, compute_sample_weight
  from ..externals.joblib import cpu_count
  from ..exceptions import ConvergenceWarning
  from ..exceptions import DataConversionWarning
label_desc: Use image node_id 7 for calling a global function with example usage: gen_batches(n, batch_size) without return types