code: def test_remove_event_handler():
      engine = DummyEngine()
  
      with pytest.raises(ValueError, match=r"Input event name"):
          engine.remove_event_handler(lambda x: x, "an event")
  
      def on_started(engine):
          return 0
  
      engine.add_event_handler(Events.STARTED, on_started)
  
      with pytest.raises(ValueError, match=r"Input handler"):
          engine.remove_event_handler(lambda x: x, Events.STARTED)
  
      h1 = MagicMock(spec_set=True)
      h2 = MagicMock(spec_set=True)
      handlers = [h1, h2]
      m = MagicMock(spec_set=True)
      for handler in handlers:
          engine.add_event_handler(Events.EPOCH_STARTED, handler)
      engine.add_event_handler(Events.EPOCH_COMPLETED, m)
  
      assert len(engine._event_handlers[Events.EPOCH_STARTED]) == 2
      engine.remove_event_handler(h1, Events.EPOCH_STARTED)
      assert len(engine._event_handlers[Events.EPOCH_STARTED]) == 1
      assert engine._event_handlers[Events.EPOCH_STARTED][0][0] == h2
  
      assert len(engine._event_handlers[Events.EPOCH_COMPLETED]) == 1
      engine.remove_event_handler(m, Events.EPOCH_COMPLETED)
      assert len(engine._event_handlers[Events.EPOCH_COMPLETED]) == 0
  
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 10 for calling a global function with example usage: test_remove_event_handler() and returns: int