code: def _set_cv(cv, estimator=None, X=None, y=None):
      """Set the default CV depending on whether clf is classifier/regressor."""
      # Detect whether classification or regression
      from sklearn.base import is_classifier
  
      if estimator in ["classifier", "regressor"]:
          est_is_classifier = estimator == "classifier"
      else:
          est_is_classifier = is_classifier(estimator)
      # Setup CV
      from sklearn import model_selection as models
      from sklearn.model_selection import (
          KFold,
          StratifiedKFold,
          check_cv,
      )
  
      if isinstance(cv, (int, np.int64)):
          XFold = StratifiedKFold if est_is_classifier else KFold
          cv = XFold(n_splits=cv)
      elif isinstance(cv, str):
          if not hasattr(models, cv):
              raise ValueError("Unknown cross-validation")
          cv = getattr(models, cv)
          cv = cv()
      cv = check_cv(cv=cv, y=y, classifier=est_is_classifier)
  
      # Extract train and test set to retrieve them at predict time
      cv_splits = [
          (train, test)
          for train, test in cv.split(X=np.zeros_like(y), y=y)
      ]
  
      if not np.all([len(train) for train, _ in cv_splits]):
          raise ValueError("Some folds do not have any train epochs.")
  
      return cv, cv_splits
  
imports: import datetime
  import numbers
  import numpy
  from ..fixes import BaseEstimator, _check_fit_params, _get_check_scoring
  from ..parallel import parallel_func
  from ..utils import verbose, warn
label_desc: Use image node_id 1 for calling a global function with example usage: _set_cv(cv, estimator, X, y) and returns: cv,  cv_splits