code: def grouping_evaluation(
      df, groupby_col, grouping_func, grouping_func_name
  ):
      """Groups ``df`` and evaluates a function on each group.
      The function takes a `pandas.DataFrame` and returns a scalar.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          Input data. For example, univariate time series, or forecast result.
          Contains ``groupby_col`` and columns to apply ``grouping_func`` on.
      groupby_col : `str`
          Column name in ``df`` to group by.
      grouping_func : `callable`
          Function that is applied to each group via `pandas.groupBy.apply`.
          Signature (grp: `pandas.DataFrame`) -> aggregated value: `float`.
      grouping_func_name : `str`
          What to call the output column generated by ``grouping_func``.
  
      Returns
      -------
      grouped_df : `pandas.DataFrame`
          Dataframe with ``grouping_func`` evaluated on each level of ``df[groupby_col]``.
          Contains two columns:
  
              - ``groupby_col``: The groupby value
              - ``grouping_func_name``: The output of ``grouping_func`` on the group
      """
      grouped_df = (
          df.groupby(groupby_col)
          .apply(grouping_func)
          .reset_index()
          .rename({0: grouping_func_name}, axis=1)
      )
  
      return grouped_df
  
imports: import warnings
  import numpy
  import pandas
  import plotly.graph_objects
  from plotly.colors import DEFAULT_PLOTLY_COLORS
  from plotly.subplots import make_subplots
  from greykite.common import constants
  from greykite.common.features.timeseries_features import build_time_features_df
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.python_utils import update_dictionary
  from greykite.common.viz.colors_utils import get_color_palette
  from greykite.common.viz.colors_utils import get_distinct_colors
label_desc: Use image node_id 7 for calling a global function with example usage: grouping_evaluation(df, groupby_col, grouping_func, grouping_func_name) and returns: grouped_df