vfdev-5: @sdesrozis can we add some tests for that ?
diff --git a/ignite/engine/utils.py b/ignite/engine/utils.py
index 41c2924f..a09c0f3f 100644
--- a/ignite/engine/utils.py
+++ b/ignite/engine/utils.py
@@ -3,7 +3,11 @@ from typing import Callable
 
 
 def _check_signature(fn: Callable, fn_description: str, *args, **kwargs) -> None:
-    signature = inspect.signature(fn)
+    # if handler with filter, check the handler rather than the decorator
+    if hasattr(fn, "_parent"):
+        signature = inspect.signature(fn._parent())
+    else:
+        signature = inspect.signature(fn)
     try:  # try without engine
         signature.bind(*args, **kwargs)
     except TypeError as exc:

Bug adding handler in case of decoration + class function + filtered event
## 🐛 Bug description

I would like to report a bug using handler defined by decorated function in a class with filtered event.

The following code reproduces all possible situations to add an handler defined w/wo decoration in a class or not, w/wo engine (or args), using an event w/wo filter

```python
engine = Engine(lambda e, b: b)

# decorator
def decorated(fun):
    @functools.wraps(fun)
    def wrapper(*args, **kwargs):
        return fun(*args, **kwargs)
    return wrapper

# handler as a function
def foo():
    print("foo")

# handler as a decorated function
@decorated
def decorated_foo():
    print("decorated_foo")

# register handler as a function -- OK
engine.add_event_handler(Events.EPOCH_STARTED, foo)
# register handler as a function with filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo)
# register handler as a decorated function -- OK
engine.add_event_handler(Events.EPOCH_STARTED, decorated_foo)
# register handler as a decorated function with filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), decorated_foo)


# handler as a function with engine (here args)
def foo_args(args):
    print("foo_args", args)


# handler as a decorated function with engine 
@decorated
def decorated_foo_args(args):
    print("decorated_foo_args", args)

# register handler as a function with engine  -- OK
engine.add_event_handler(Events.EPOCH_STARTED, foo_args)
# register handler as a function with engine and filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo_args)
# register handler as a decorated function with engine -- OK
engine.add_event_handler(Events.EPOCH_STARTED, decorated_foo_args)
# register handler as a decorated function with engine and filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), decorated_foo_args)

class Foo:
    # handler as a class function (ie method)
    def foo(self):
        print("foo")

    # handler as a decorated method
    @decorated
    def decorated_foo(self):
        print("decorated_foo")

    # handler as a method with engine
    def foo_args(self, args):
        print("foo_args", args)

    # handler as a decorated method with engine
    @decorated
    def decorated_foo_args(self, args):
        print("decorated_foo_args", args)


foo = Foo()

# register handler as a method -- OK
engine.add_event_handler(Events.EPOCH_STARTED, foo.foo)
# register handler as a method with filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.foo)
# register handler as a decorated method -- OK
engine.add_event_handler(Events.EPOCH_STARTED, foo.decorated_foo)
# register handler as a decorated method with filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.decorated_foo)
# register handler as a method with engine  -- OK
engine.add_event_handler(Events.EPOCH_STARTED, foo.foo_args)
# register handler as a method with engine and filter -- OK
engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.foo_args)
# register handler as a decorated method with engine -- OK
engine.add_event_handler(Events.EPOCH_STARTED, foo.decorated_foo_args)

# register handler as a decorated method with engine and filter -- FAILED
engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.decorated_foo_args)

engine.run([0])
```

The error is
```
Error adding <function Foo.decorated_foo_args at 0x1229b6af0> 'handler': takes parameters ['self', 'args'] but will be called with [](missing a required argument: 'self').
```

Why ? 

First, a handler defined with a filtered event is wrapped with decoration. See https://github.com/sdesrozis/ignite/blob/93be57aa3f71ce601391d59096c3b430c4d9487b/ignite/engine/engine.py#L198. Note that `functools.wraps` is used to fit the signature of the related handler.

The failed case is decorated method with engine. So, I guess `functools.wraps` works perfectly and catch `self` and `engine` as arguments. But the signature checking search (using `inspect.signature`) fails because missing `self`... 

See signature checking
https://github.com/pytorch/ignite/blob/0de7156bb284bd01d788252469a3b386f10abbd7/ignite/engine/utils.py#L5

I think this is related to `follow_wrapped=True` argument of `inspect.signature`.

## Environment

 - PyTorch Version (e.g., 1.4): 1.5
 - Ignite Version (e.g., 0.3.0): 0.4
 - OS (e.g., Linux): MacOS
 - How you installed Ignite (`conda`, `pip`, source): Honda
 - Python version: 3.7
 - Any other relevant information:


diff --git a/tests/ignite/engine/test_event_handlers.py b/tests/ignite/engine/test_event_handlers.py
index fa1a1ec6..5b8abbb3 100644
--- a/tests/ignite/engine/test_event_handlers.py
+++ b/tests/ignite/engine/test_event_handlers.py
@@ -1,3 +1,4 @@
+import functools
 import gc
 from unittest.mock import MagicMock, call, create_autospec
 
@@ -471,3 +472,78 @@ def test_custom_exception_handler():
 
     # only one call from _run_once_over_data, since the exception is swallowed
     assert len(counter.exceptions) == 1 and counter.exceptions[0] == value_error
+
+
+def test_event_handlers_with_decoration():
+
+    engine = Engine(lambda e, b: b)
+
+    def decorated(fun):
+        @functools.wraps(fun)
+        def wrapper(*args, **kwargs):
+            return fun(*args, **kwargs)
+
+        return wrapper
+
+    values = []
+
+    def foo():
+        values.append("foo")
+
+    @decorated
+    def decorated_foo():
+        values.append("decorated_foo")
+
+    engine.add_event_handler(Events.EPOCH_STARTED, foo)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo)
+    engine.add_event_handler(Events.EPOCH_STARTED, decorated_foo)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), decorated_foo)
+
+    def foo_args(e):
+        values.append("foo_args")
+        values.append(e.state.iteration)
+
+    @decorated
+    def decorated_foo_args(e):
+        values.append("decorated_foo_args")
+        values.append(e.state.iteration)
+
+    engine.add_event_handler(Events.EPOCH_STARTED, foo_args)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo_args)
+    engine.add_event_handler(Events.EPOCH_STARTED, decorated_foo_args)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), decorated_foo_args)
+
+    class Foo:
+        def __init__(self):
+            self.values = []
+
+        def foo(self):
+            self.values.append("foo")
+
+        @decorated
+        def decorated_foo(self):
+            self.values.append("decorated_foo")
+
+        def foo_args(self, e):
+            self.values.append("foo_args")
+            self.values.append(e.state.iteration)
+
+        @decorated
+        def decorated_foo_args(self, e):
+            self.values.append("decorated_foo_args")
+            self.values.append(e.state.iteration)
+
+    foo = Foo()
+
+    engine.add_event_handler(Events.EPOCH_STARTED, foo.foo)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.foo)
+    engine.add_event_handler(Events.EPOCH_STARTED, foo.decorated_foo)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.decorated_foo)
+    engine.add_event_handler(Events.EPOCH_STARTED, foo.foo_args)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.foo_args)
+    engine.add_event_handler(Events.EPOCH_STARTED, foo.decorated_foo_args)
+    engine.add_event_handler(Events.EPOCH_STARTED(every=2), foo.decorated_foo_args)
+
+    engine.run([0], max_epochs=2)
+
+    assert values == foo.values

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc pip install torch torchvision -f https://download.pytorch.org/whl/cpu/torch_stable.html -U
3.7
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
absl-py==2.1.0
alembic==1.12.1
arrow==1.2.3
attrs==24.2.0
boto3==1.33.13
botocore==1.33.13
bravado==11.1.0
bravado-core==6.1.1
cached-property==1.5.2
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
click==7.1.2
cloudpickle==2.2.1
codecov==2.1.13
coverage==7.2.7
cycler==0.11.0
databricks-cli==0.18.0
dill==0.3.7
docker==6.1.3
entrypoints==0.4
exceptiongroup==1.2.2
execnet==2.0.2
Flask==1.1.4
fonttools==4.38.0
fqdn==1.5.1
funcsigs==1.0.2
furl==2.1.4
future==1.0.0
gitdb==4.0.12
GitPython==3.1.44
google-auth==2.38.0
google-auth-oauthlib==0.4.6
greenlet==3.1.1
grpcio==1.62.3
gunicorn==20.1.0
gym==0.26.2
gym-notices==0.0.8
hestia==0.6.0
humanfriendly==10.0
idna==3.10
importlib-metadata==5.2.0
importlib-resources==5.12.0
iniconfig==2.0.0
isoduration==20.11.0
itsdangerous==1.1.0
Jinja2==2.10.3
jmespath==1.0.1
joblib==1.3.2
jsonpatch==1.33
jsonpointer==3.0.0
jsonref==1.1.0
jsonschema==4.17.3
kiwisolver==1.4.5
Mako==1.2.4
Markdown==3.4.4
MarkupSafe==2.1.5
marshmallow==3.0.0rc5
matplotlib==3.5.3
mlflow==1.30.1
monotonic==1.6
msgpack==1.0.5
neptune-client==1.11.1
networkx==2.6.3
numpy==1.21.6
oauthlib==3.2.2
orderedmultidict==1.0.1
packaging==21.3
pandas==1.3.5
pathlib2==2.3.7.post1
Pillow==9.5.0
pkgutil_resolve_name==1.3.10
pluggy==1.2.0
polyaxon-client==0.6.1
polyaxon-schemas==0.6.1
polystores==0.2.5
prometheus-client==0.17.1
prometheus_flask_exporter==0.23.2
protobuf==3.20.3
psutil==7.0.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
PyJWT==2.8.0
pynvml==11.5.3
pyparsing==3.1.4
pyrsistent==0.19.3
pytest==7.4.4
pytest-cov==4.1.0
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
-e git+https://github.com/pytorch/ignite.git@7635e03f5af8ec6a89583f54cc0d6ad36cd05166#egg=pytorch_ignite
pytz==2022.7.1
PyYAML==6.0.1
querystring-parser==1.2.4
requests==2.31.0
requests-file==2.1.0
requests-oauthlib==2.0.0
requests-toolbelt==1.0.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rhea==0.5.5
rsa==4.9
s3transfer==0.8.2
scikit-learn==1.0.2
scipy==1.7.3
simplejson==3.20.1
six==1.17.0
smmap==5.0.2
SQLAlchemy==1.4.54
sqlparse==0.4.4
swagger-spec-validator==3.0.3
tabulate==0.9.0
tensorboard==2.11.2
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorboardX==2.6.2.2
threadpoolctl==3.1.0
tomli==2.0.1
torch==1.13.1+cpu
torchvision==0.14.1+cpu
tornado==6.2
tqdm==4.67.1
trains==0.16.4
typing_extensions==4.7.1
uri-template==1.3.0
urllib3==1.26.20
visdom==0.2.4
webcolors==1.13
websocket-client==1.6.1
Werkzeug==1.0.1
zipp==3.15.0

name: ignite
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - absl-py==2.1.0
      - alembic==1.12.1
      - arrow==1.2.3
      - attrs==24.2.0
      - boto3==1.33.13
      - botocore==1.33.13
      - bravado==11.1.0
      - bravado-core==6.1.1
      - cached-property==1.5.2
      - cachetools==5.5.2
      - charset-normalizer==3.4.1
      - click==7.1.2
      - cloudpickle==2.2.1
      - codecov==2.1.13
      - coverage==7.2.7
      - cycler==0.11.0
      - databricks-cli==0.18.0
      - dill==0.3.7
      - docker==6.1.3
      - entrypoints==0.4
      - exceptiongroup==1.2.2
      - execnet==2.0.2
      - flask==1.1.4
      - fonttools==4.38.0
      - fqdn==1.5.1
      - funcsigs==1.0.2
      - furl==2.1.4
      - future==1.0.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - google-auth==2.38.0
      - google-auth-oauthlib==0.4.6
      - greenlet==3.1.1
      - grpcio==1.62.3
      - gunicorn==20.1.0
      - gym==0.26.2
      - gym-notices==0.0.8
      - hestia==0.6.0
      - humanfriendly==10.0
      - idna==3.10
      - importlib-metadata==5.2.0
      - importlib-resources==5.12.0
      - iniconfig==2.0.0
      - isoduration==20.11.0
      - itsdangerous==1.1.0
      - jinja2==2.10.3
      - jmespath==1.0.1
      - joblib==1.3.2
      - jsonpatch==1.33
      - jsonpointer==3.0.0
      - jsonref==1.1.0
      - jsonschema==4.17.3
      - kiwisolver==1.4.5
      - mako==1.2.4
      - markdown==3.4.4
      - markupsafe==2.1.5
      - marshmallow==3.0.0rc5
      - matplotlib==3.5.3
      - mlflow==1.30.1
      - monotonic==1.6
      - msgpack==1.0.5
      - neptune-client==1.11.1
      - networkx==2.6.3
      - numpy==1.21.6
      - oauthlib==3.2.2
      - orderedmultidict==1.0.1
      - packaging==21.3
      - pandas==1.3.5
      - pathlib2==2.3.7.post1
      - pillow==9.5.0
      - pkgutil-resolve-name==1.3.10
      - pluggy==1.2.0
      - polyaxon-client==0.6.1
      - polyaxon-schemas==0.6.1
      - polystores==0.2.5
      - prometheus-client==0.17.1
      - prometheus-flask-exporter==0.23.2
      - protobuf==3.20.3
      - psutil==7.0.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pyjwt==2.8.0
      - pynvml==11.5.3
      - pyparsing==3.1.4
      - pyrsistent==0.19.3
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - pytest-xdist==3.5.0
      - python-dateutil==2.9.0.post0
      - pytorch-ignite==0.4.0
      - pytz==2022.7.1
      - pyyaml==6.0.1
      - querystring-parser==1.2.4
      - requests==2.31.0
      - requests-file==2.1.0
      - requests-oauthlib==2.0.0
      - requests-toolbelt==1.0.0
      - rfc3339-validator==0.1.4
      - rfc3986-validator==0.1.1
      - rhea==0.5.5
      - rsa==4.9
      - s3transfer==0.8.2
      - scikit-learn==1.0.2
      - scipy==1.7.3
      - simplejson==3.20.1
      - six==1.17.0
      - smmap==5.0.2
      - sqlalchemy==1.4.54
      - sqlparse==0.4.4
      - swagger-spec-validator==3.0.3
      - tabulate==0.9.0
      - tensorboard==2.11.2
      - tensorboard-data-server==0.6.1
      - tensorboard-plugin-wit==1.8.1
      - tensorboardx==2.6.2.2
      - threadpoolctl==3.1.0
      - tomli==2.0.1
      - torch==1.13.1+cpu
      - torchvision==0.14.1+cpu
      - tornado==6.2
      - tqdm==4.67.1
      - trains==0.16.4
      - typing-extensions==4.7.1
      - uri-template==1.3.0
      - urllib3==1.26.20
      - visdom==0.2.4
      - webcolors==1.13
      - websocket-client==1.6.1
      - werkzeug==1.0.1
      - zipp==3.15.0
prefix: /opt/conda/envs/ignite

tests/ignite/engine/test_event_handlers.py::test_event_handlers_with_decoration
tests/ignite/engine/test_event_handlers.py::test_add_event_handler_raises_with_invalid_event tests/ignite/engine/test_event_handlers.py::test_add_event_handler_raises_with_invalid_signature tests/ignite/engine/test_event_handlers.py::test_add_event_handler tests/ignite/engine/test_event_handlers.py::test_add_event_handler_without_engine tests/ignite/engine/test_event_handlers.py::test_adding_multiple_event_handlers tests/ignite/engine/test_event_handlers.py::test_event_removable_handle tests/ignite/engine/test_event_handlers.py::test_events_list_removable_handle tests/ignite/engine/test_event_handlers.py::test_eventslist__append_raises tests/ignite/engine/test_event_handlers.py::test_has_event_handler tests/ignite/engine/test_event_handlers.py::test_remove_event_handler tests/ignite/engine/test_event_handlers.py::test_args_and_kwargs_are_passed_to_event tests/ignite/engine/test_event_handlers.py::test_on_decorator_raises_with_invalid_event tests/ignite/engine/test_event_handlers.py::test_on_decorator tests/ignite/engine/test_event_handlers.py::test_returns_state tests/ignite/engine/test_event_handlers.py::test_state_attributes tests/ignite/engine/test_event_handlers.py::test_default_exception_handler tests/ignite/engine/test_event_handlers.py::test_custom_exception_handler
ignite/engine/utils.py
ignite/engine/utils.py