code: def _fit_and_score(
      fold, estimator, y, X, scorer, train, test, verbose, error_score
  ):
      """Fit estimator and compute scores for a given dataset split."""
      msg = "fold=%i" % fold
      if verbose > 1:
          print("[CV] %s %s" % (msg, (64 - len(msg)) * "."))
  
      start_time = time.time()
      y_train, y_test, X_train, X_test = _safe_split(y, X, train, test)
  
      try:
          estimator.fit(y_train, X=X_train)
  
      except Exception as e:
          fit_time = time.time() - start_time
          score_time = 0.0
          if error_score == "raise":
              raise
          else:
              test_scores = error_score
              warnings.warn(
                  "Estimator fit failed. The score on this train-test "
                  "partition will be set to %f. Details: \n%s"
                  % (error_score, format_exception_only(type(e), e)[0]),
                  ModelFitWarning,
              )
  
      else:
          fit_time = time.time() - start_time
  
          # forecast h periods into the future and compute the score
          preds = estimator.predict(n_periods=len(test), X=X_test)
          test_scores = scorer(y_test, preds)
          score_time = time.time() - start_time - fit_time
  
      if verbose > 2:
          total_time = score_time + fit_time
          msg += ", score=%.3f [time=%.3f sec]" % (
              test_scores,
              total_time,
          )
          print(msg)
  
      # TODO: if we ever want train scores, we'll need to change this signature
      return test_scores, fit_time, score_time
  
imports: import numpy
  import numbers
  import warnings
  import time
  from traceback import format_exception_only
  from sklearn import base
  from sklearn.metrics import mean_absolute_error, mean_squared_error
  from sklearn.utils import indexable
  from ._split import check_cv
  from ..None import metrics
  from ..utils import check_endog
  from ..warnings import ModelFitWarning
  from ..compat.sklearn import safe_indexing
label_desc: Use image node_id 5 for calling a global function with example usage: _fit_and_score(fold, estimator, y, X, scorer, train, test, verbose, error_score) and returns: test_scores,  fit_time,  score_time