code: def _fit_and_predict(
      estimator, X, y, train, test, verbose, fit_params, method
  ):
      """Fit estimator and predict values for a given dataset split.
  
      Read more in the :ref:`User Guide <cross_validation>`.
  
      Parameters
      ----------
      estimator : estimator object implementing 'fit' and 'predict'
          The object to use to fit the data.
  
      X : array-like of shape at least 2D
          The data to fit.
  
      y : array-like, optional, default: None
          The target variable to try to predict in the case of
          supervised learning.
  
      train : array-like, shape (n_train_samples,)
          Indices of training samples.
  
      test : array-like, shape (n_test_samples,)
          Indices of test samples.
  
      verbose : integer
          The verbosity level.
  
      fit_params : dict or None
          Parameters that will be passed to ``estimator.fit``.
  
      method : string
          Invokes the passed method name of the passed estimator.
  
      Returns
      -------
      predictions : sequence
          Result of calling 'estimator.method'
  
      test : array-like
          This is the value of the test parameter
      """
      # Adjust length of sample weights
      fit_params = fit_params if fit_params is not None else {}
      fit_params = dict(
          [
              (k, _index_param_value(X, v, train))
              for k, v in fit_params.items()
          ]
      )
  
      X_train, y_train = _safe_split(estimator, X, y, train)
      X_test, _ = _safe_split(estimator, X, y, test, train)
  
      if y_train is None:
          estimator.fit(X_train, **fit_params)
      else:
          estimator.fit(X_train, y_train, **fit_params)
      func = getattr(estimator, method)
      predictions = func(X_test)
      return predictions, test
  
imports: from __future__ import print_function
  from __future__ import division
  import warnings
  import numbers
  import time
  import numpy
  import scipy.sparse
  from ..base import is_classifier, clone
  from ..utils import indexable, check_random_state, safe_indexing
  from ..utils.fixes import astype
  from ..utils.validation import _is_arraylike, _num_samples
  from ..utils.metaestimators import _safe_split
  from ..externals.joblib import Parallel, delayed, logger
  from ..metrics.scorer import check_scoring
  from ..exceptions import FitFailedWarning
  from ._split import check_cv
label_desc: Use image node_id 5 for calling a global function with example usage: _fit_and_predict(estimator, X, y, train, test, verbose, fit_params, method) and returns: predictions,  test