code: def test_add_event_handler_without_engine():
      engine = DummyEngine()
  
      class Counter(object):
          def __init__(self, count=0):
              self.count = count
  
      started_counter = Counter()
  
      def handle_iteration_started():
          started_counter.count += 1
  
      engine.add_event_handler(Events.STARTED, handle_iteration_started)
  
      completed_counter = Counter()
  
      def handle_iteration_completed(counter):
          counter.count += 1
  
      engine.add_event_handler(
          Events.COMPLETED,
          handle_iteration_completed,
          completed_counter,
      )
  
      engine.run(15)
  
      assert started_counter.count == 15
      assert completed_counter.count == 15
  
imports: import functools
  import gc
  from unittest.mock import call, create_autospec, MagicMock
  import pytest
  from pytest import raises
  from ignite.engine import Engine, Events, State
  from ignite.engine.events import EventsList
label_desc: Use image node_id 4 for calling a global function with example usage: test_add_event_handler_without_engine() without return types