code: def _fit_and_predict(fold, estimator, y, X, train, test, verbose):
      """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, _, X_train, X_test = _safe_split(y, X, train, test)
  
      # scikit doesn't handle failures on cv predict, so we won't either.
      estimator.fit(y_train, X=X_train)
      fit_time = time.time() - start_time
  
      # forecast h periods into the future
      start_time = time.time()
      preds = estimator.predict(n_periods=len(test), X=X_test)
      pred_time = time.time() - start_time
  
      if verbose > 2:
          total_time = pred_time + fit_time
          msg += " [time=%.3f sec]" % (total_time)
          print(msg)
  
      return preds, test
  
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 6 for calling a global function with example usage: _fit_and_predict(fold, estimator, y, X, train, test, verbose) and returns: preds,  test