code: def test_aggregation_chain():
      """test the aggregation chain with a single event attribute"""
  
      class _EventInterface(ABC):
          @define_epoch_stats(sum)
          @define_episode_stats(sum)
          @define_step_stats(sum)
          def event1(self, attr1):
              pass
  
      agg_episode = LogStatsAggregator(LogStatsLevel.EPOCH)
      agg_step = LogStatsAggregator(LogStatsLevel.EPISODE, agg_episode)
      agg_event = LogStatsAggregator(LogStatsLevel.STEP, agg_step)
  
      no_steps = 5
      no_episodes = 7
      for episode in range(no_episodes):
          for step in range(no_steps):
              agg_event.add_event(
                  EventRecord(
                      _EventInterface,
                      _EventInterface.event1,
                      dict(attr1=2),
                  )
              )
              agg_event.add_event(
                  EventRecord(
                      _EventInterface,
                      _EventInterface.event1,
                      dict(attr1=3),
                  )
              )
              agg_event.reduce()
  
          episode_stats = agg_step.reduce()
          assert len(episode_stats) == 1
          value = episode_stats[(_EventInterface.event1, None, None)]
          assert value == no_steps * 5
  
      epoch_stats = agg_episode.reduce()
      assert len(epoch_stats) == 1
      value = epoch_stats[(_EventInterface.event1, None, None)]
      assert value == no_episodes * no_steps * 5
  
file_path: maze/maze/test/core/test_log_stats.py
imports: from abc import ABC
  import numpy
  import pytest
  from maze.core.events.event_record import EventRecord
  from maze.core.log_stats.event_decorators import define_step_stats, define_episode_stats, define_epoch_stats, define_stats_grouping
  from maze.core.log_stats.log_stats import LogStatsAggregator, LogStatsLevel
  from maze.core.log_stats.reducer_functions import histogram
label_desc: Use image node_id 5 for calling a global function with example usage: test_aggregation_chain() without return types