code: def gen_even_slices(n, n_packs, *, n_samples=None):
      """Generator to create `n_packs` evenly spaced slices going up to `n`.
  
      If `n_packs` does not divide `n`, except for the first `n % n_packs`
      slices, remaining slices may contain fewer elements.
  
      Parameters
      ----------
      n : int
          Size of the sequence.
      n_packs : int
          Number of slices to generate.
      n_samples : int, default=None
          Number of samples. Pass `n_samples` when the slices are to be used for
          sparse matrix indexing; slicing off-the-end raises an exception, while
          it works for NumPy arrays.
  
      Yields
      ------
      `slice` representing a set of indices from 0 to n.
  
      See Also
      --------
      gen_batches: Generator to create slices containing batch_size elements
          from 0 to n.
  
      Examples
      --------
      >>> from sklearn.utils import gen_even_slices
      >>> list(gen_even_slices(10, 1))
      [slice(0, 10, None)]
      >>> list(gen_even_slices(10, 10))
      [slice(0, 1, None), slice(1, 2, None), ..., slice(9, 10, None)]
      >>> list(gen_even_slices(10, 5))
      [slice(0, 2, None), slice(2, 4, None), ..., slice(8, 10, None)]
      >>> list(gen_even_slices(10, 3))
      [slice(0, 4, None), slice(4, 7, None), slice(7, 10, None)]
      """
      start = 0
      for pack_num in range(n_packs):
          this_n = n // n_packs
          if pack_num < n % n_packs:
              this_n += 1
          if this_n > 0:
              end = start + this_n
              if n_samples is not None:
                  end = min(n_samples, end)
              yield slice(start, end, None)
              start = end
  
imports: import math
  import numbers
  import platform
  import struct
  import timeit
  import warnings
  from collections.abc import Sequence
  from contextlib import contextmanager, suppress
  from itertools import compress, islice
  import numpy
  from scipy.sparse import issparse
  from ..None import get_config
  from ..exceptions import DataConversionWarning
  from .None import _joblib, metadata_routing
  from ._bunch import Bunch
  from ._estimator_html_repr import estimator_html_repr
  from ._param_validation import Integral, Interval, validate_params
  from .class_weight import compute_class_weight, compute_sample_weight
  from .deprecation import deprecated
  from .discovery import all_estimators
  from .fixes import parse_version, threadpool_info
  from .murmurhash import murmurhash3_32
  from .validation import _is_arraylike_not_scalar, _is_pandas_df, _is_polars_df, _use_interchange_protocol, as_float_array, assert_all_finite, check_array, check_consistent_length, check_random_state, check_scalar, check_symmetric, check_X_y, column_or_1d, indexable
label_desc: Use image node_id 19 for calling a global function with example usage: gen_even_slices(n, n_packs) without return types