code: def test_get_scoring_and_refit():
      """Tests `get_scoring_and_refit`"""
      enum = EvaluationMetricEnum.MeanAbsolutePercentError
      scoring, refit = get_scoring_and_refit()
      assert_refit(
          refit,
          expected_metric=enum.get_metric_name(),
          expected_greater_is_better=enum.get_metric_greater_is_better(),
      )
      expected_keys = {enum.get_metric_name()}
      assert_scoring(scoring=scoring, expected_keys=expected_keys)
  
      # Tests all parameters where `score_func_greater_is_better=True`,
      # `score_func` is contained in `cv_report_metrics`,
      # and `cv_report_metrics=CV_REPORT_METRICS_ALL`.
      enum = EvaluationMetricEnum.Correlation
      agg_periods = 7
      agg_func = np.sum
      relative_error_tolerance = 0.025
      scoring, refit = get_scoring_and_refit(
          score_func=enum.name,
          score_func_greater_is_better=enum.get_metric_greater_is_better(),
          cv_report_metrics=CV_REPORT_METRICS_ALL,
          agg_periods=agg_periods,
          agg_func=agg_func,
          relative_error_tolerance=relative_error_tolerance,
      )
      assert_refit(
          refit,
          expected_metric=enum.get_metric_name(),
          expected_greater_is_better=enum.get_metric_greater_is_better(),
      )
      enum_names = set(
          enum.get_metric_name() for enum in EvaluationMetricEnum
      )
      assert_scoring(
          scoring=scoring,
          expected_keys=enum_names | {FRACTION_OUTSIDE_TOLERANCE_NAME},
          agg_periods=agg_periods,
          agg_func=agg_func,
          relative_error_tolerance=relative_error_tolerance,
      )
  
      # score_func is a callable,
      # `cv_report_metrics=CV_REPORT_METRICS_ALL`,
      # and `relative_error_tolerance=None`
      relative_error_tolerance = None
      scoring, refit = get_scoring_and_refit(
          score_func=mean_absolute_error,
          score_func_greater_is_better=False,
          cv_report_metrics=CV_REPORT_METRICS_ALL,
          agg_periods=None,
          agg_func=None,
          relative_error_tolerance=relative_error_tolerance,
      )
      assert_refit(
          refit,
          expected_metric=CUSTOM_SCORE_FUNC_NAME,  # custom name for callable
          expected_greater_is_better=False,
      )
      assert_scoring(
          scoring=scoring,
          expected_keys=enum_names
          | {
              CUSTOM_SCORE_FUNC_NAME
          },  # does not include `FRACTION_OUTSIDE_TOLERANCE_NAME`
          agg_periods=None,
          agg_func=None,
          relative_error_tolerance=relative_error_tolerance,
      )
      assert_eval_function_equal(
          scoring[CUSTOM_SCORE_FUNC_NAME]._score_func,
          mean_absolute_error,
      )
  
      # `score_func=FRACTION_OUTSIDE_TOLERANCE`, cv_report_metrics is a list
      relative_error_tolerance = 0.025
      cv_report_metrics = [
          EvaluationMetricEnum.MeanAbsolutePercentError.name,
          EvaluationMetricEnum.MeanSquaredError.name,
      ]
      scoring, refit = get_scoring_and_refit(
          score_func=FRACTION_OUTSIDE_TOLERANCE,
          score_func_greater_is_better=False,
          cv_report_metrics=cv_report_metrics,
          agg_periods=None,
          agg_func=None,
          relative_error_tolerance=relative_error_tolerance,
      )
      assert_refit(
          refit,
          expected_metric=FRACTION_OUTSIDE_TOLERANCE_NAME,
          expected_greater_is_better=False,
      )
      assert_scoring(
          scoring=scoring,
          expected_keys={
              EvaluationMetricEnum.MeanAbsolutePercentError.get_metric_name(),
              EvaluationMetricEnum.MeanSquaredError.get_metric_name(),
              FRACTION_OUTSIDE_TOLERANCE_NAME,
          },
          agg_periods=None,
          agg_func=None,
          relative_error_tolerance=relative_error_tolerance,
      )
  
imports: import sys
  import warnings
  from functools import partial
  import numpy
  import pandas
  import pytest
  from scipy.stats import randint
  from sklearn.metrics import mean_absolute_error
  from sklearn.metrics import mean_squared_error
  from sklearn.metrics import median_absolute_error
  from sklearn.pipeline import Pipeline
  from testfixtures import LogCapture
  from greykite.common import constants
  from greykite.common.constants import FRACTION_OUTSIDE_TOLERANCE
  from greykite.common.constants import LOGGER_NAME
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.evaluation import add_preaggregation_to_scorer
  from greykite.common.evaluation import fraction_outside_tolerance
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import assert_eval_function_equal
  from greykite.common.testing_utils import generate_df_for_tests
  from greykite.common.testing_utils import generate_df_with_reg_for_tests
  from greykite.framework.constants import CUSTOM_SCORE_FUNC_NAME
  from greykite.framework.constants import CV_REPORT_METRICS_ALL
  from greykite.framework.constants import FRACTION_OUTSIDE_TOLERANCE_NAME
  from greykite.framework.pipeline.utils import get_basic_pipeline
  from greykite.framework.pipeline.utils import get_best_index
  from greykite.framework.pipeline.utils import get_default_time_parameters
  from greykite.framework.pipeline.utils import get_forecast
  from greykite.framework.pipeline.utils import get_hyperparameter_searcher
  from greykite.framework.pipeline.utils import get_score_func_with_aggregation
  from greykite.framework.pipeline.utils import get_scoring_and_refit
  from greykite.framework.utils.framework_testing_utils import assert_proper_grid_search
  from greykite.framework.utils.framework_testing_utils import assert_refit
  from greykite.framework.utils.framework_testing_utils import assert_scoring
  from greykite.sklearn.cross_validation import RollingTimeSeriesSplit
  from greykite.sklearn.estimator.null_model import DummyEstimator
  from greykite.sklearn.estimator.prophet_estimator import ProphetEstimator
  from greykite.sklearn.estimator.silverkite_estimator import SilverkiteEstimator
  from greykite.sklearn.transform.column_selector import ColumnSelector
label_desc: Use image node_id 8 for calling a global function with example usage: test_get_scoring_and_refit() without return types