code: def test_custom_exception_handler():
      value_error = ValueError()
      update_function = MagicMock(side_effect=value_error)
  
      engine = Engine(update_function)
  
      class ExceptionCounter(object):
          def __init__(self):
              self.exceptions = []
  
          def __call__(self, engine, e):
              self.exceptions.append(e)
  
      counter = ExceptionCounter()
      engine.add_event_handler(Events.EXCEPTION_RAISED, counter)
      engine.run([1])
  
      # only one call from _run_once_over_data, since the exception is swallowed
      assert (
          len(counter.exceptions) == 1
          and counter.exceptions[0] == value_error
      )
  
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 17 for calling a global function with example usage: test_custom_exception_handler() without return types