class_docstr: Parallelization is based predominantly on [1]. Also similar to [2]
  
  Ref:
  [1] https://github.com/scikit-learn/scikit-learn/blob/0.24.1/sklearn/model_selection/_search.py#L795
  [2] https://github.com/scikit-optimize/scikit-optimize/blob/v0.8.1/skopt/searchcv.py#L410
class_docstr_tok: ["Parallelization","is","based","predominantly","on","[","1","]",".","Also","similar","to","[","2","]","Ref",":","[","1","]","https",":","\/\/github.com\/scikit-learn\/scikit-learn\/blob\/0.24.1\/sklearn\/model_selection\/_search.py","#","L795","[","2","]","https",":","\/\/github.com\/scikit-optimize\/scikit-optimize\/blob\/v0.8.1\/skopt\/searchcv.py","#","L410"]
docstr: From sklearn and sktime
docstr_tok: ["From","sklearn","and","sktime"]
code: def _format_results(candidate_params, scorers, out, n_splits):
      """From sklearn and sktime"""
      n_candidates = len(candidate_params)
      (test_scores_dict, fit_time, score_time, cutoffs) = zip(*out)
      test_scores_dict = _aggregate_score_dicts(test_scores_dict)
  
      results = {}
  
      # From sklearn (with the addition of greater_is_better from sktime)
      # INFO: For some reason, sklearn func does not work with sktime metrics
      # without passing greater_is_better (as done in sktime) and processing
      # it as such.
      def _store(
          key_name,
          array,
          weights=None,
          splits=False,
          rank=False,
          greater_is_better=False,
      ):
          """A small helper to store the scores/times to the cv_results_"""
          # When iterated first by splits, then by parameters
          # We want `array` to have `n_candidates` rows and `n_splits` cols.
          array = np.array(array, dtype=np.float64).reshape(
              n_candidates, n_splits
          )
          if splits:
              for split_idx in range(n_splits):
                  # Uses closure to alter the results
                  results["split%d_%s" % (split_idx, key_name)] = array[
                      :, split_idx
                  ]
  
          array_means = np.average(array, axis=1, weights=weights)
          results["mean_%s" % key_name] = array_means
  
          if key_name.startswith(("train_", "test_")) and np.any(
              ~np.isfinite(array_means)
          ):
              warnings.warn(
                  f"One or more of the {key_name.split('_')[0]} scores "
                  f"are non-finite: {array_means}",
                  category=UserWarning,
              )
  
          # Weighted std is not directly available in numpy
          array_stds = np.sqrt(
              np.average(
                  (array - array_means[:, np.newaxis]) ** 2,
                  axis=1,
                  weights=weights,
              )
          )
          results["std_%s" % key_name] = array_stds
  
          if rank:
              # This section is taken from sktime
              array_means = (
                  -array_means if greater_is_better else array_means
              )
              results["rank_%s" % key_name] = np.asarray(
                  rankdata(array_means, method="min"), dtype=np.int32
              )
  
      _store("fit_time", fit_time)
      _store("score_time", score_time)
      # Use one MaskedArray and mask all the places where the param is not
      # applicable for that candidate. Use defaultdict as each candidate may
      # not contain all the params
      param_results = defaultdict(
          partial(
              np.ma.MaskedArray,
              np.empty(n_candidates),
              mask=True,
              dtype=object,
          )
      )
      for cand_i, params in enumerate(candidate_params):
          for name, value in params.items():
              # An all masked empty array gets created for the key
              # `"param_%s" % name` at the first occurrence of `name`.
              # Setting the value at an index also unmasks that index
              param_results["param_%s" % name][cand_i] = value
  
      results.update(param_results)
      # Store a list of param dicts at the key "params"
      results["params"] = candidate_params
  
      for scorer_name, scorer in scorers.items():
          # Computed the (weighted) mean and std for test scores alone
          _store(
              "test_%s" % scorer_name,
              test_scores_dict[scorer_name],
              splits=True,
              rank=True,
              weights=None,
              greater_is_better=True if scorer._sign == 1 else False,
          )
  
      return results
  
imports: import time
  import warnings
  from collections import defaultdict
  from functools import partial
  from typing import Any, Dict, Generator, List, Optional, Tuple, Union
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from scipy.stats import rankdata
  from sklearn.base import clone
  from sklearn.metrics._scorer import _PredictScorer
  from sklearn.model_selection import ParameterGrid, ParameterSampler, check_cv
  from sklearn.model_selection._validation import _aggregate_score_dicts
  from sktime.forecasting.compose import ForecastingPipeline
  from sktime.forecasting.model_selection import ExpandingWindowSplitter, SlidingWindowSplitter
  from sktime.utils.validation.forecasting import check_y_X
  from pycaret.internal.logging import get_logger
  from pycaret.utils.generic import _get_metrics_dict, get_function_params
  from pycaret.utils.time_series.forecasting import get_predictions_with_intervals, update_additional_scorer_kwargs
  from pycaret.utils.time_series.forecasting.pipeline import _get_imputed_data
label_desc: Use image node_id 3 for calling the BaseGridSearch obj's underlying member method code with example usage: obj._format_results(candidate_params, scorers, out, n_splits) and returns: results