code: def define_step_stats(
      reduce_function: Optional[Callable],
      input_name: Optional[str] = None,
      output_name: Optional[str] = None,
      group_by: Optional[str] = None,
      cumulative: bool = False,
  ) -> Callable:
      """
      Event method decorator, defines a new step statistics calculation for this event.
  
      :input: all events in a single step (and side-loaded step statistics, see 'reduce_function' set to None)
      :output: step statistics
  
      :param reduce_function: A function that takes a list of values and returns the calculated statistics.
                              In the special case that we do not want to calculate the statistics from events,
                              but have the statistics result already available for the current step, the reduce_function
                              can be set to None. Then the event can be invoked at most once per step to side-load the
                              result. This is very useful to log state information, e.g. the inventory size.
      :param input_name: The name of the event attribute (=keyword attribute), whose values are to be passed
                         to the reduce function.
                         Can be omitted, for which there are two reasons
  
                         * no naming necessary, there is only a single event attribute
                         * we want all event attributes to be passed to the reduce_function as dictionaries (or our
                           reduce function does not care, e.g. counting the number of events with `len`)
  
      :param output_name: The name of the statistics, how it should be passed to the logger resp. the following
                          aggregation stage. Will be the same as input_name if None is provided.
      :param group_by: If there are multiple groups defined for an event, per default the statistics
                       is collected at the 'cell' level. This option allows to project the statistics
                       onto a single group (e.g. for inventory statistics we might define location and product as
                       groups, but prefer to monitor statistics grouped only per product, regardless of location
                       and vice versa)
      :param cumulative: Enable cumulative statistics
  
      :return: The decorator function
      """
      return _decorator_factory(
          LogStatsLevel.STEP,
          reduce_function,
          input_name,
          output_name,
          group_by,
          cumulative,
      )
  
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 5 for calling a global function with example usage: define_step_stats(reduce_function, input_name, output_name, group_by, cumulative) and returns: _decorator_factory