code: def define_stats_grouping(*group_by: str) -> Callable:
      """
      Event method decorator, defines a grouping of all calculated statistics by an attribute.
  
      :param group_by: Name of the event attribute(s)
  
      :return: The decorator function
      """
  
      def decorator(func_obj):
          """
          :param func_obj: The actual function to be decorated
          :return The unmodified function object (required by the Python decorator semantics)
          """
          existing_group_by = getattr(func_obj, "group_by", None)
          assert (
              existing_group_by is None
          ), "more than one stats_grouping decorator detected"
  
          setattr(func_obj, "group_by", group_by)
  
          return func_obj
  
      return decorator
  
file_path: maze/maze/core/log_stats/event_decorators.py
imports: import inspect
  from collections import defaultdict
  from typing import Callable, Optional, List, Dict
  from maze.core.log_stats.log_stats import LogStatsLevel
label_desc: Use image node_id 8 for calling a global function with example usage: define_stats_grouping() and returns: decorator, func_obj