We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
correct the type hints of this function
https://github.com/pytorch/ignite/blob/ca738d8f3f106093aa04b6bce9506129a1059df8/ignite/engine/events.py#L81

this really should read

`    def wrapper(engine, event: int) -> bool:`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ignite/engine/events.py`
Content:
```
1 
2 from typing import Callable, Optional, Union, Any
3 
4 from enum import Enum
5 import numbers
6 import weakref
7 
8 from ignite.engine.utils import _check_signature
9 
10 
11 __all__ = [
12     'Events',
13     'State'
14 ]
15 
16 
17 class EventWithFilter:
18 
19     def __init__(self, event: Any, filter: Callable):
20         if not callable(filter):
21             raise TypeError("Argument filter should be callable")
22         self.event = event
23         self.filter = filter
24 
25     def __str__(self) -> str:
26         return "<%s event=%s, filter=%r>" % (self.__class__.__name__, self.event, self.filter)
27 
28 
29 class CallableEvents:
30     """Base class for Events implementing call operator and storing event filter. This class should be inherited
31     for any custom events with event filtering feature:
32 
33     .. code-block:: python
34 
35         from ignite.engine.engine import CallableEvents
36 
37         class CustomEvents(CallableEvents, Enum):
38             TEST_EVENT = "test_event"
39 
40         engine = ...
41         engine.register_events(*CustomEvents, event_to_attr={CustomEvents.TEST_EVENT: "test_event"})
42 
43         @engine.on(CustomEvents.TEST_EVENT(every=5))
44         def call_on_test_event_every(engine):
45             # do something
46 
47     """
48 
49     def __call__(self, event_filter: Optional[Callable] = None,
50                  every: Optional[int] = None, once: Optional[int] = None):
51 
52         if not ((event_filter is not None) ^ (every is not None) ^ (once is not None)):
53             raise ValueError("Only one of the input arguments should be specified")
54 
55         if (event_filter is not None) and not callable(event_filter):
56             raise TypeError("Argument event_filter should be a callable")
57 
58         if (every is not None) and not (isinstance(every, numbers.Integral) and every > 0):
59             raise ValueError("Argument every should be integer and greater than zero")
60 
61         if (once is not None) and not (isinstance(once, numbers.Integral) and once > 0):
62             raise ValueError("Argument every should be integer and positive")
63 
64         if every is not None:
65             if every == 1:
66                 # Just return the event itself
67                 return self
68             event_filter = CallableEvents.every_event_filter(every)
69 
70         if once is not None:
71             event_filter = CallableEvents.once_event_filter(once)
72 
73         # check signature:
74         _check_signature("engine", event_filter, "event_filter", "event")
75 
76         return EventWithFilter(self, event_filter)
77 
78     @staticmethod
79     def every_event_filter(every: int) -> Callable:
80         def wrapper(engine, event: bool):
81             if event % every == 0:
82                 return True
83             return False
84 
85         return wrapper
86 
87     @staticmethod
88     def once_event_filter(once: int) -> Callable:
89         def wrapper(engine, event: int) -> bool:
90             if event == once:
91                 return True
92             return False
93 
94         return wrapper
95 
96 
97 class Events(CallableEvents, Enum):
98     """Events that are fired by the :class:`~ignite.engine.Engine` during execution.
99 
100     Since v0.3.0, Events become more flexible and allow to pass an event filter to the Engine:
101 
102     .. code-block:: python
103 
104         engine = Engine()
105 
106         # a) custom event filter
107         def custom_event_filter(engine, event):
108             if event in [1, 2, 5, 10, 50, 100]:
109                 return True
110             return False
111 
112         @engine.on(Events.ITERATION_STARTED(event_filter=custom_event_filter))
113         def call_on_special_event(engine):
114              # do something on 1, 2, 5, 10, 50, 100 iterations
115 
116         # b) "every" event filter
117         @engine.on(Events.ITERATION_STARTED(every=10))
118         def call_every(engine):
119             # do something every 10th iteration
120 
121         # c) "once" event filter
122         @engine.on(Events.ITERATION_STARTED(once=50))
123         def call_once(engine):
124             # do something on 50th iteration
125 
126     Event filter function `event_filter` accepts as input `engine` and `event` and should return True/False.
127     Argument `event` is the value of iteration or epoch, depending on which type of Events the function is passed.
128 
129     """
130     EPOCH_STARTED = "epoch_started"
131     EPOCH_COMPLETED = "epoch_completed"
132     STARTED = "started"
133     COMPLETED = "completed"
134     ITERATION_STARTED = "iteration_started"
135     ITERATION_COMPLETED = "iteration_completed"
136     EXCEPTION_RAISED = "exception_raised"
137 
138     GET_BATCH_STARTED = "get_batch_started"
139     GET_BATCH_COMPLETED = "get_batch_completed"
140 
141 
142 class State:
143     """An object that is used to pass internal and user-defined state between event handlers. By default, state
144     contains the following attributes:
145 
146     .. code-block:: python
147 
148         state.iteration         # 1-based, the first iteration is 1
149         state.epoch             # 1-based, the first epoch is 1
150         state.seed              # seed to set at each epoch
151         state.dataloader        # data passed to engine
152         state.epoch_length      # optional length of an epoch
153         state.max_epochs        # number of epochs to run
154         state.batch             # batch passed to `process_function`
155         state.output            # output of `process_function` after a single iteration
156         state.metrics           # dictionary with defined metrics if any
157 
158     """
159 
160     event_to_attr = {
161         Events.GET_BATCH_STARTED: "iteration",
162         Events.GET_BATCH_COMPLETED: "iteration",
163         Events.ITERATION_STARTED: "iteration",
164         Events.ITERATION_COMPLETED: "iteration",
165         Events.EPOCH_STARTED: "epoch",
166         Events.EPOCH_COMPLETED: "epoch",
167         Events.STARTED: "epoch",
168         Events.COMPLETED: "epoch",
169     }
170 
171     def __init__(self, **kwargs):
172         self.iteration = 0
173         self.epoch = 0
174         self.epoch_length = None
175         self.max_epochs = None
176         self.output = None
177         self.batch = None
178         self.metrics = {}
179         self.dataloader = None
180         self.seed = None
181 
182         for k, v in kwargs.items():
183             setattr(self, k, v)
184 
185         for value in self.event_to_attr.values():
186             if not hasattr(self, value):
187                 setattr(self, value, 0)
188 
189     def get_event_attrib_value(self, event_name: Union[EventWithFilter, CallableEvents, Enum]) -> int:
190         if isinstance(event_name, EventWithFilter):
191             event_name = event_name.event
192         if event_name not in State.event_to_attr:
193             raise RuntimeError("Unknown event name '{}'".format(event_name))
194         return getattr(self, State.event_to_attr[event_name])
195 
196     def __repr__(self) -> str:
197         s = "State:\n"
198         for attr, value in self.__dict__.items():
199             if not isinstance(value, (numbers.Number, str)):
200                 value = type(value)
201             s += "\t{}: {}\n".format(attr, value)
202         return s
203 
204 
205 class RemovableEventHandle:
206     """A weakref handle to remove a registered event.
207 
208     A handle that may be used to remove a registered event handler via the
209     remove method, with-statement, or context manager protocol. Returned from
210     :meth:`~ignite.engine.Engine.add_event_handler`.
211 
212 
213     Args:
214         event_name: Registered event name.
215         handler: Registered event handler, stored as weakref.
216         engine: Target engine, stored as weakref.
217 
218     Example usage:
219 
220     .. code-block:: python
221 
222         engine = Engine()
223 
224         def print_epoch(engine):
225             print("Epoch: {}".format(engine.state.epoch))
226 
227         with engine.add_event_handler(Events.EPOCH_COMPLETED, print_epoch):
228             # print_epoch handler registered for a single run
229             engine.run(data)
230 
231         # print_epoch handler is now unregistered
232     """
233 
234     def __init__(self, event_name: Union[EventWithFilter, CallableEvents, Enum], handler: Callable, engine):
235         self.event_name = event_name
236         self.handler = weakref.ref(handler)
237         self.engine = weakref.ref(engine)
238 
239     def remove(self) -> None:
240         """Remove handler from engine."""
241         handler = self.handler()
242         engine = self.engine()
243 
244         if handler is None or engine is None:
245             return
246 
247         if engine.has_event_handler(handler, self.event_name):
248             engine.remove_event_handler(handler, self.event_name)
249 
250     def __enter__(self):
251         return self
252 
253     def __exit__(self, *args, **kwargs) -> None:
254         self.remove()
255
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ignite/engine/events.py b/ignite/engine/events.py
--- a/ignite/engine/events.py
+++ b/ignite/engine/events.py
@@ -77,7 +77,7 @@
 
     @staticmethod
     def every_event_filter(every: int) -> Callable:
-        def wrapper(engine, event: bool):
+        def wrapper(engine, event: int) -> bool:
             if event % every == 0:
                 return True
             return False

{"golden_diff": "diff --git a/ignite/engine/events.py b/ignite/engine/events.py\n--- a/ignite/engine/events.py\n+++ b/ignite/engine/events.py\n@@ -77,7 +77,7 @@\n \n     @staticmethod\n     def every_event_filter(every: int) -> Callable:\n-        def wrapper(engine, event: bool):\n+        def wrapper(engine, event: int) -> bool:\n             if event % every == 0:\n                 return True\n             return False\n", "issue": "correct the type hints of this function\nhttps://github.com/pytorch/ignite/blob/ca738d8f3f106093aa04b6bce9506129a1059df8/ignite/engine/events.py#L81\r\n\r\nthis really should read\r\n\r\n`    def wrapper(engine, event: int) -> bool:`\n", "before_files": [{"content": "\nfrom typing import Callable, Optional, Union, Any\n\nfrom enum import Enum\nimport numbers\nimport weakref\n\nfrom ignite.engine.utils import _check_signature\n\n\n__all__ = [\n    'Events',\n    'State'\n]\n\n\nclass EventWithFilter:\n\n    def __init__(self, event: Any, filter: Callable):\n        if not callable(filter):\n            raise TypeError(\"Argument filter should be callable\")\n        self.event = event\n        self.filter = filter\n\n    def __str__(self) -> str:\n        return \"<%s event=%s, filter=%r>\" % (self.__class__.__name__, self.event, self.filter)\n\n\nclass CallableEvents:\n    \"\"\"Base class for Events implementing call operator and storing event filter. This class should be inherited\n    for any custom events with event filtering feature:\n\n    .. code-block:: python\n\n        from ignite.engine.engine import CallableEvents\n\n        class CustomEvents(CallableEvents, Enum):\n            TEST_EVENT = \"test_event\"\n\n        engine = ...\n        engine.register_events(*CustomEvents, event_to_attr={CustomEvents.TEST_EVENT: \"test_event\"})\n\n        @engine.on(CustomEvents.TEST_EVENT(every=5))\n        def call_on_test_event_every(engine):\n            # do something\n\n    \"\"\"\n\n    def __call__(self, event_filter: Optional[Callable] = None,\n                 every: Optional[int] = None, once: Optional[int] = None):\n\n        if not ((event_filter is not None) ^ (every is not None) ^ (once is not None)):\n            raise ValueError(\"Only one of the input arguments should be specified\")\n\n        if (event_filter is not None) and not callable(event_filter):\n            raise TypeError(\"Argument event_filter should be a callable\")\n\n        if (every is not None) and not (isinstance(every, numbers.Integral) and every > 0):\n            raise ValueError(\"Argument every should be integer and greater than zero\")\n\n        if (once is not None) and not (isinstance(once, numbers.Integral) and once > 0):\n            raise ValueError(\"Argument every should be integer and positive\")\n\n        if every is not None:\n            if every == 1:\n                # Just return the event itself\n                return self\n            event_filter = CallableEvents.every_event_filter(every)\n\n        if once is not None:\n            event_filter = CallableEvents.once_event_filter(once)\n\n        # check signature:\n        _check_signature(\"engine\", event_filter, \"event_filter\", \"event\")\n\n        return EventWithFilter(self, event_filter)\n\n    @staticmethod\n    def every_event_filter(every: int) -> Callable:\n        def wrapper(engine, event: bool):\n            if event % every == 0:\n                return True\n            return False\n\n        return wrapper\n\n    @staticmethod\n    def once_event_filter(once: int) -> Callable:\n        def wrapper(engine, event: int) -> bool:\n            if event == once:\n                return True\n            return False\n\n        return wrapper\n\n\nclass Events(CallableEvents, Enum):\n    \"\"\"Events that are fired by the :class:`~ignite.engine.Engine` during execution.\n\n    Since v0.3.0, Events become more flexible and allow to pass an event filter to the Engine:\n\n    .. code-block:: python\n\n        engine = Engine()\n\n        # a) custom event filter\n        def custom_event_filter(engine, event):\n            if event in [1, 2, 5, 10, 50, 100]:\n                return True\n            return False\n\n        @engine.on(Events.ITERATION_STARTED(event_filter=custom_event_filter))\n        def call_on_special_event(engine):\n             # do something on 1, 2, 5, 10, 50, 100 iterations\n\n        # b) \"every\" event filter\n        @engine.on(Events.ITERATION_STARTED(every=10))\n        def call_every(engine):\n            # do something every 10th iteration\n\n        # c) \"once\" event filter\n        @engine.on(Events.ITERATION_STARTED(once=50))\n        def call_once(engine):\n            # do something on 50th iteration\n\n    Event filter function `event_filter` accepts as input `engine` and `event` and should return True/False.\n    Argument `event` is the value of iteration or epoch, depending on which type of Events the function is passed.\n\n    \"\"\"\n    EPOCH_STARTED = \"epoch_started\"\n    EPOCH_COMPLETED = \"epoch_completed\"\n    STARTED = \"started\"\n    COMPLETED = \"completed\"\n    ITERATION_STARTED = \"iteration_started\"\n    ITERATION_COMPLETED = \"iteration_completed\"\n    EXCEPTION_RAISED = \"exception_raised\"\n\n    GET_BATCH_STARTED = \"get_batch_started\"\n    GET_BATCH_COMPLETED = \"get_batch_completed\"\n\n\nclass State:\n    \"\"\"An object that is used to pass internal and user-defined state between event handlers. By default, state\n    contains the following attributes:\n\n    .. code-block:: python\n\n        state.iteration         # 1-based, the first iteration is 1\n        state.epoch             # 1-based, the first epoch is 1\n        state.seed              # seed to set at each epoch\n        state.dataloader        # data passed to engine\n        state.epoch_length      # optional length of an epoch\n        state.max_epochs        # number of epochs to run\n        state.batch             # batch passed to `process_function`\n        state.output            # output of `process_function` after a single iteration\n        state.metrics           # dictionary with defined metrics if any\n\n    \"\"\"\n\n    event_to_attr = {\n        Events.GET_BATCH_STARTED: \"iteration\",\n        Events.GET_BATCH_COMPLETED: \"iteration\",\n        Events.ITERATION_STARTED: \"iteration\",\n        Events.ITERATION_COMPLETED: \"iteration\",\n        Events.EPOCH_STARTED: \"epoch\",\n        Events.EPOCH_COMPLETED: \"epoch\",\n        Events.STARTED: \"epoch\",\n        Events.COMPLETED: \"epoch\",\n    }\n\n    def __init__(self, **kwargs):\n        self.iteration = 0\n        self.epoch = 0\n        self.epoch_length = None\n        self.max_epochs = None\n        self.output = None\n        self.batch = None\n        self.metrics = {}\n        self.dataloader = None\n        self.seed = None\n\n        for k, v in kwargs.items():\n            setattr(self, k, v)\n\n        for value in self.event_to_attr.values():\n            if not hasattr(self, value):\n                setattr(self, value, 0)\n\n    def get_event_attrib_value(self, event_name: Union[EventWithFilter, CallableEvents, Enum]) -> int:\n        if isinstance(event_name, EventWithFilter):\n            event_name = event_name.event\n        if event_name not in State.event_to_attr:\n            raise RuntimeError(\"Unknown event name '{}'\".format(event_name))\n        return getattr(self, State.event_to_attr[event_name])\n\n    def __repr__(self) -> str:\n        s = \"State:\\n\"\n        for attr, value in self.__dict__.items():\n            if not isinstance(value, (numbers.Number, str)):\n                value = type(value)\n            s += \"\\t{}: {}\\n\".format(attr, value)\n        return s\n\n\nclass RemovableEventHandle:\n    \"\"\"A weakref handle to remove a registered event.\n\n    A handle that may be used to remove a registered event handler via the\n    remove method, with-statement, or context manager protocol. Returned from\n    :meth:`~ignite.engine.Engine.add_event_handler`.\n\n\n    Args:\n        event_name: Registered event name.\n        handler: Registered event handler, stored as weakref.\n        engine: Target engine, stored as weakref.\n\n    Example usage:\n\n    .. code-block:: python\n\n        engine = Engine()\n\n        def print_epoch(engine):\n            print(\"Epoch: {}\".format(engine.state.epoch))\n\n        with engine.add_event_handler(Events.EPOCH_COMPLETED, print_epoch):\n            # print_epoch handler registered for a single run\n            engine.run(data)\n\n        # print_epoch handler is now unregistered\n    \"\"\"\n\n    def __init__(self, event_name: Union[EventWithFilter, CallableEvents, Enum], handler: Callable, engine):\n        self.event_name = event_name\n        self.handler = weakref.ref(handler)\n        self.engine = weakref.ref(engine)\n\n    def remove(self) -> None:\n        \"\"\"Remove handler from engine.\"\"\"\n        handler = self.handler()\n        engine = self.engine()\n\n        if handler is None or engine is None:\n            return\n\n        if engine.has_event_handler(handler, self.event_name):\n            engine.remove_event_handler(handler, self.event_name)\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, *args, **kwargs) -> None:\n        self.remove()\n", "path": "ignite/engine/events.py"}], "after_files": [{"content": "\nfrom typing import Callable, Optional, Union, Any\n\nfrom enum import Enum\nimport numbers\nimport weakref\n\nfrom ignite.engine.utils import _check_signature\n\n\n__all__ = [\n    'Events',\n    'State'\n]\n\n\nclass EventWithFilter:\n\n    def __init__(self, event: Any, filter: Callable):\n        if not callable(filter):\n            raise TypeError(\"Argument filter should be callable\")\n        self.event = event\n        self.filter = filter\n\n    def __str__(self) -> str:\n        return \"<%s event=%s, filter=%r>\" % (self.__class__.__name__, self.event, self.filter)\n\n\nclass CallableEvents:\n    \"\"\"Base class for Events implementing call operator and storing event filter. This class should be inherited\n    for any custom events with event filtering feature:\n\n    .. code-block:: python\n\n        from ignite.engine.engine import CallableEvents\n\n        class CustomEvents(CallableEvents, Enum):\n            TEST_EVENT = \"test_event\"\n\n        engine = ...\n        engine.register_events(*CustomEvents, event_to_attr={CustomEvents.TEST_EVENT: \"test_event\"})\n\n        @engine.on(CustomEvents.TEST_EVENT(every=5))\n        def call_on_test_event_every(engine):\n            # do something\n\n    \"\"\"\n\n    def __call__(self, event_filter: Optional[Callable] = None,\n                 every: Optional[int] = None, once: Optional[int] = None):\n\n        if not ((event_filter is not None) ^ (every is not None) ^ (once is not None)):\n            raise ValueError(\"Only one of the input arguments should be specified\")\n\n        if (event_filter is not None) and not callable(event_filter):\n            raise TypeError(\"Argument event_filter should be a callable\")\n\n        if (every is not None) and not (isinstance(every, numbers.Integral) and every > 0):\n            raise ValueError(\"Argument every should be integer and greater than zero\")\n\n        if (once is not None) and not (isinstance(once, numbers.Integral) and once > 0):\n            raise ValueError(\"Argument every should be integer and positive\")\n\n        if every is not None:\n            if every == 1:\n                # Just return the event itself\n                return self\n            event_filter = CallableEvents.every_event_filter(every)\n\n        if once is not None:\n            event_filter = CallableEvents.once_event_filter(once)\n\n        # check signature:\n        _check_signature(\"engine\", event_filter, \"event_filter\", \"event\")\n\n        return EventWithFilter(self, event_filter)\n\n    @staticmethod\n    def every_event_filter(every: int) -> Callable:\n        def wrapper(engine, event: int) -> bool:\n            if event % every == 0:\n                return True\n            return False\n\n        return wrapper\n\n    @staticmethod\n    def once_event_filter(once: int) -> Callable:\n        def wrapper(engine, event: int) -> bool:\n            if event == once:\n                return True\n            return False\n\n        return wrapper\n\n\nclass Events(CallableEvents, Enum):\n    \"\"\"Events that are fired by the :class:`~ignite.engine.Engine` during execution.\n\n    Since v0.3.0, Events become more flexible and allow to pass an event filter to the Engine:\n\n    .. code-block:: python\n\n        engine = Engine()\n\n        # a) custom event filter\n        def custom_event_filter(engine, event):\n            if event in [1, 2, 5, 10, 50, 100]:\n                return True\n            return False\n\n        @engine.on(Events.ITERATION_STARTED(event_filter=custom_event_filter))\n        def call_on_special_event(engine):\n             # do something on 1, 2, 5, 10, 50, 100 iterations\n\n        # b) \"every\" event filter\n        @engine.on(Events.ITERATION_STARTED(every=10))\n        def call_every(engine):\n            # do something every 10th iteration\n\n        # c) \"once\" event filter\n        @engine.on(Events.ITERATION_STARTED(once=50))\n        def call_once(engine):\n            # do something on 50th iteration\n\n    Event filter function `event_filter` accepts as input `engine` and `event` and should return True/False.\n    Argument `event` is the value of iteration or epoch, depending on which type of Events the function is passed.\n\n    \"\"\"\n    EPOCH_STARTED = \"epoch_started\"\n    EPOCH_COMPLETED = \"epoch_completed\"\n    STARTED = \"started\"\n    COMPLETED = \"completed\"\n    ITERATION_STARTED = \"iteration_started\"\n    ITERATION_COMPLETED = \"iteration_completed\"\n    EXCEPTION_RAISED = \"exception_raised\"\n\n    GET_BATCH_STARTED = \"get_batch_started\"\n    GET_BATCH_COMPLETED = \"get_batch_completed\"\n\n\nclass State:\n    \"\"\"An object that is used to pass internal and user-defined state between event handlers. By default, state\n    contains the following attributes:\n\n    .. code-block:: python\n\n        state.iteration         # 1-based, the first iteration is 1\n        state.epoch             # 1-based, the first epoch is 1\n        state.seed              # seed to set at each epoch\n        state.dataloader        # data passed to engine\n        state.epoch_length      # optional length of an epoch\n        state.max_epochs        # number of epochs to run\n        state.batch             # batch passed to `process_function`\n        state.output            # output of `process_function` after a single iteration\n        state.metrics           # dictionary with defined metrics if any\n\n    \"\"\"\n\n    event_to_attr = {\n        Events.GET_BATCH_STARTED: \"iteration\",\n        Events.GET_BATCH_COMPLETED: \"iteration\",\n        Events.ITERATION_STARTED: \"iteration\",\n        Events.ITERATION_COMPLETED: \"iteration\",\n        Events.EPOCH_STARTED: \"epoch\",\n        Events.EPOCH_COMPLETED: \"epoch\",\n        Events.STARTED: \"epoch\",\n        Events.COMPLETED: \"epoch\",\n    }\n\n    def __init__(self, **kwargs):\n        self.iteration = 0\n        self.epoch = 0\n        self.epoch_length = None\n        self.max_epochs = None\n        self.output = None\n        self.batch = None\n        self.metrics = {}\n        self.dataloader = None\n        self.seed = None\n\n        for k, v in kwargs.items():\n            setattr(self, k, v)\n\n        for value in self.event_to_attr.values():\n            if not hasattr(self, value):\n                setattr(self, value, 0)\n\n    def get_event_attrib_value(self, event_name: Union[EventWithFilter, CallableEvents, Enum]) -> int:\n        if isinstance(event_name, EventWithFilter):\n            event_name = event_name.event\n        if event_name not in State.event_to_attr:\n            raise RuntimeError(\"Unknown event name '{}'\".format(event_name))\n        return getattr(self, State.event_to_attr[event_name])\n\n    def __repr__(self) -> str:\n        s = \"State:\\n\"\n        for attr, value in self.__dict__.items():\n            if not isinstance(value, (numbers.Number, str)):\n                value = type(value)\n            s += \"\\t{}: {}\\n\".format(attr, value)\n        return s\n\n\nclass RemovableEventHandle:\n    \"\"\"A weakref handle to remove a registered event.\n\n    A handle that may be used to remove a registered event handler via the\n    remove method, with-statement, or context manager protocol. Returned from\n    :meth:`~ignite.engine.Engine.add_event_handler`.\n\n\n    Args:\n        event_name: Registered event name.\n        handler: Registered event handler, stored as weakref.\n        engine: Target engine, stored as weakref.\n\n    Example usage:\n\n    .. code-block:: python\n\n        engine = Engine()\n\n        def print_epoch(engine):\n            print(\"Epoch: {}\".format(engine.state.epoch))\n\n        with engine.add_event_handler(Events.EPOCH_COMPLETED, print_epoch):\n            # print_epoch handler registered for a single run\n            engine.run(data)\n\n        # print_epoch handler is now unregistered\n    \"\"\"\n\n    def __init__(self, event_name: Union[EventWithFilter, CallableEvents, Enum], handler: Callable, engine):\n        self.event_name = event_name\n        self.handler = weakref.ref(handler)\n        self.engine = weakref.ref(engine)\n\n    def remove(self) -> None:\n        \"\"\"Remove handler from engine.\"\"\"\n        handler = self.handler()\n        engine = self.engine()\n\n        if handler is None or engine is None:\n            return\n\n        if engine.has_event_handler(handler, self.event_name):\n            engine.remove_event_handler(handler, self.event_name)\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, *args, **kwargs) -> None:\n        self.remove()\n", "path": "ignite/engine/events.py"}]}