code: def _shuffle(y, groups, random_state):
      """Return a shuffled copy of y eventually shuffle among same groups."""
      if groups is None:
          indices = random_state.permutation(len(y))
      else:
          indices = np.arange(len(groups))
          for group in np.unique(groups):
              this_mask = groups == group
              indices[this_mask] = random_state.permutation(
                  indices[this_mask]
              )
      return _safe_indexing(y, indices)
  
imports: import numbers
  import time
  import warnings
  from collections import Counter
  from contextlib import suppress
  from functools import partial
  from numbers import Real
  from traceback import format_exc
  import numpy
  import scipy.sparse
  from joblib import logger
  from ..base import clone, is_classifier
  from ..exceptions import FitFailedWarning
  from ..metrics import check_scoring, get_scorer_names
  from ..metrics._scorer import _check_multimetric_scoring, _MultimetricScorer
  from ..preprocessing import LabelEncoder
  from ..utils import _safe_indexing, check_random_state, indexable
  from ..utils._param_validation import HasMethods, Integral, Interval, StrOptions, validate_params
  from ..utils.metaestimators import _safe_split
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _check_fit_params, _num_samples
  from ._split import check_cv
label_desc: Use image node_id 14 for calling a global function with example usage: _shuffle(y, groups, random_state) and returns: _safe_indexing