code: def test_get_score_func_with_aggregation():
      """Tests get_score_func_with_aggregation function"""
      # tests callable score function
      score_func = mean_absolute_error
      greater_is_better = False
      (
          score_func,
          greater_is_better,
          short_name,
      ) = get_score_func_with_aggregation(
          score_func,
          greater_is_better=greater_is_better,
          agg_periods=None,
          agg_func=None,
      )
      assert_eval_function_equal(score_func, mean_absolute_error)
      assert greater_is_better is False
      assert short_name == CUSTOM_SCORE_FUNC_NAME
  
      # tests `EvaluationMetricEnum` string lookup
      score_func = "MedianAbsoluteError"
      greater_is_better = True  # should be overridden
      (
          score_func,
          greater_is_better,
          short_name,
      ) = get_score_func_with_aggregation(
          score_func,
          greater_is_better=greater_is_better,
          agg_periods=None,
          agg_func=None,
      )
      assert_eval_function_equal(score_func, median_absolute_error)
      assert greater_is_better is False
      assert (
          short_name
          == EvaluationMetricEnum.MedianAbsoluteError.get_metric_name()
      )
  
      # tests `FRACTION_OUTSIDE_TOLERANCE_NAME` lookup
      score_func = FRACTION_OUTSIDE_TOLERANCE
      greater_is_better = True  # should be overridden
      (
          score_func,
          greater_is_better,
          short_name,
      ) = get_score_func_with_aggregation(
          score_func,
          greater_is_better=greater_is_better,
          agg_periods=None,
          agg_func=None,
          relative_error_tolerance=0.02,
      )
      assert_eval_function_equal(
          score_func, partial(fraction_outside_tolerance, rtol=0.02)
      )
      assert greater_is_better is False
      assert short_name == FRACTION_OUTSIDE_TOLERANCE_NAME
  
      # tests exception
      with pytest.raises(
          NotImplementedError, match=r"Evaluation metric.*not available"
      ):
          get_score_func_with_aggregation("unknown_estimator")
  
      with pytest.raises(
          ValueError,
          match="Must specify `relative_error_tolerance` to request "
          "FRACTION_OUTSIDE_TOLERANCE as a metric.",
      ):
          get_score_func_with_aggregation(
              score_func=FRACTION_OUTSIDE_TOLERANCE
          )
      with pytest.raises(
          ValueError,
          match="`score_func` must be an `EvaluationMetricEnum` member name, "
          "FRACTION_OUTSIDE_TOLERANCE, or callable.",
      ):
          get_score_func_with_aggregation(score_func=["wrong_type"])
  
      # tests preaggregation on score function
      with pytest.warns(UserWarning) as record:
          (
              score_func,
              greater_is_better,
              short_name,
          ) = get_score_func_with_aggregation(
              "MeanAbsoluteError",
              greater_is_better=False,
              agg_periods=3,
              agg_func=np.sum,
          )
          assert_eval_function_equal(
              score_func,
              add_preaggregation_to_scorer(
                  mean_absolute_error, agg_periods=3, agg_func=np.sum
              ),
          )
          assert greater_is_better is False
          assert (
              short_name
              == EvaluationMetricEnum.MeanAbsoluteError.get_metric_name()
          )
  
          y_true = pd.Series(
              [3, 1, np.nan, 3, np.Inf]
          )  # np.nan and np.Inf are ignored
          y_pred = pd.Series([1, 4, 100, 2, -2])
          assert score_func(y_true, y_pred) == 0.0  # 7 vs 7
          assert (
              "Requested agg_periods=3, but there are only 1. Using all for aggregation"
              in record[0].message.args[0]
          )
          assert (
              "2 value(s) in y_true were NA or infinite and are omitted in error calc."
              in record[4].message.args[0]
          )
  
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 7 for calling a global function with example usage: test_get_score_func_with_aggregation() without return types