code: def test_grouping_evaluation():
      """Tests grouping_evaluation function"""
      groupby_col = "custom_groups"
      df = pd.DataFrame(
          {
              cst.TIME_COL: [
                  datetime.datetime(2018, 1, 1),
                  datetime.datetime(2018, 1, 2),
                  datetime.datetime(2018, 1, 3),
                  datetime.datetime(2018, 1, 4),
                  datetime.datetime(2018, 1, 5),
              ],
              cst.VALUE_COL: [1.0, 2.0, 3.0, 4.0, 5.0],
              groupby_col: ["g1", "g2", "g1", "g3", "g2"],
          }
      )
  
      # grouping function on one column
      def grouping_func_min(grp):
          return np.min(grp[cst.VALUE_COL])
  
      grouping_func_name = "min"
      grouped_df = grouping_evaluation(
          df=df,
          groupby_col=groupby_col,
          grouping_func=grouping_func_min,
          grouping_func_name=grouping_func_name,
      )
      expected = pd.DataFrame(
          {
              groupby_col: ["g1", "g2", "g3"],
              grouping_func_name: [1.0, 2.0, 4.0],
          }
      )
      assert_frame_equal(grouped_df, expected)
  
      # grouping function on two columns
      df[cst.ACTUAL_COL] = pd.Series([1.0, 2.0, 3.0, 4.0, 5.0])
      df[cst.PREDICTED_COL] = pd.Series([1.0, 4.0, 3.0, 2.0, 3.0])
  
      metric = EvaluationMetricEnum.MeanAbsolutePercentError
      score_func = metric.get_metric_func()
  
      def grouping_func_mape(grp):
          return score_func(grp[cst.ACTUAL_COL], grp[cst.PREDICTED_COL])
  
      grouped_df = grouping_evaluation(
          df=df,
          groupby_col=groupby_col,
          grouping_func=grouping_func_mape,
          grouping_func_name=metric.get_metric_name(),
      )
      expected = pd.DataFrame(
          {
              groupby_col: ["g1", "g2", "g3"],
              metric.get_metric_name(): [0.0, 70.0, 50.0],
          }
      )
      assert_frame_equal(grouped_df, expected)
  
imports: import datetime
  from datetime import datetime
  from functools import partial
  import numpy
  import pandas
  import pytest
  from pandas.testing import assert_frame_equal
  from plotly.colors import DEFAULT_PLOTLY_COLORS
  from testfixtures import LogCapture
  import greykite.common.constants
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.viz.timeseries_plotting import add_groupby_column
  from greykite.common.viz.timeseries_plotting import flexible_grouping_evaluation
  from greykite.common.viz.timeseries_plotting import grouping_evaluation
  from greykite.common.viz.timeseries_plotting import plot_dual_axis_figure
  from greykite.common.viz.timeseries_plotting import plot_forecast_vs_actual
  from greykite.common.viz.timeseries_plotting import plot_multivariate
  from greykite.common.viz.timeseries_plotting import plot_multivariate_grouped
  from greykite.common.viz.timeseries_plotting import plot_univariate
  from greykite.common.viz.timeseries_plotting import split_range_into_groups
label_desc: Use image node_id 7 for calling a global function with example usage: test_grouping_evaluation() and returns: np, score_func