vfdev-5: @jkhenning seems like `test_trains_disk_saver_integration` is broken now:
https://travis-ci.org/github/pytorch/ignite/jobs/687746212#L1952
diff --git a/ignite/contrib/handlers/trains_logger.py b/ignite/contrib/handlers/trains_logger.py
index a4f39029..3bb490fb 100644
--- a/ignite/contrib/handlers/trains_logger.py
+++ b/ignite/contrib/handlers/trains_logger.py
@@ -577,7 +577,17 @@ class TrainsLogger(BaseLogger):
 
 
 class TrainsSaver(DiskSaver):
-    """Handler that saves input checkpoint as Trains artifacts
+    """
+    Handler that saves input checkpoint as Trains artifacts
+
+    Args:
+        logger (TrainsLogger, optional): An instance of :class:`~ignite.contrib.handlers.TrainsLogger`, ensuring a valid
+            Trains ``Task`` has been initialized. If not provided, and a Trains Task has not been manually initialized,
+            a runtime error will be raised.
+        output_uri (str, optional): The default location for output models and other artifacts uploaded by Trains. For
+            more information, see ``trains.Task.init``.
+        dirname (str, optional): Directory path where the checkpoint will be saved. If not provided, a temporary
+            directory will be created.
 
     Examples:
 
@@ -595,7 +605,7 @@ class TrainsSaver(DiskSaver):
 
             handler = Checkpoint(
                 to_save,
-                TrainsSaver(trains_logger),
+                TrainsSaver(),
                 n_saved=1,
                 score_function=lambda e: 123,
                 score_name="acc",
@@ -607,10 +617,7 @@ class TrainsSaver(DiskSaver):
 
     """
 
-    def __init__(self, logger: TrainsLogger, output_uri: str = None, dirname: str = None, *args, **kwargs):
-        if not isinstance(logger, TrainsLogger):
-            raise TypeError("logger must be an instance of TrainsLogger")
-
+    def __init__(self, logger: TrainsLogger = None, output_uri: str = None, dirname: str = None, *args, **kwargs):
         try:
             from trains import Task
         except ImportError:
@@ -619,6 +626,16 @@ class TrainsSaver(DiskSaver):
                 "You may install trains using: \n pip install trains \n"
             )
 
+        if logger and not isinstance(logger, TrainsLogger):
+            raise TypeError("logger must be an instance of TrainsLogger")
+
+        self.task = Task.current_task()
+        if not self.task:
+            raise RuntimeError(
+                "TrainsSaver requires a Trains Task to be initialized."
+                "Please use the `logger` argument or call `trains.Task.init()`."
+            )
+
         if not dirname:
             dirname = tempfile.mkdtemp(
                 prefix="ignite_checkpoints_{}".format(datetime.now().strftime("%Y_%m_%d_%H_%M_%S_"))
@@ -627,9 +644,6 @@ class TrainsSaver(DiskSaver):
 
         super(TrainsSaver, self).__init__(dirname=dirname, *args, **kwargs)
 
-        self.logger = logger
-        self.task = Task.current_task()
-
         if output_uri:
             self.task.output_uri = output_uri
 

TrainsSaver requires TrainsLogger but doesn't use it
## ❓ Questions/Help/Support

<!-- If you have a question, please checkout other issues labelled as "question" (https://github.com/pytorch/ignite/issues?q=is%3Aissue+is%3Aopen+label%3Aquestion) -->
<!-- If your question is not listed above or you need a support or help, please provide a description-->
<!-- If you prefer, you can also reach out us on [Discussion Forum](https://discuss.pytorch.org/) adding tag "ignite". -->

Hi,

I'm opening this issue as a question, because I'm not sure if it's an artifact or it has an intended purpose that I don't understand.

The new trains support introduced `TrainsSaver` together with `TrainsLogger`.  It seems that to initialize the `TrainsSaver` object, you're required to pass a `TrainsLogger` logger (https://github.com/pytorch/ignite/blob/master/ignite/contrib/handlers/trains_logger.py#L610).
However, this logger is not used anywhere. Why is it required?

I would expect to be able to just do 
```
Checkpoint(to_save, TrainsSaver(output_uri=output_uri), 'epoch', n_saved=n_saved,
                       global_step_transform=global_step_from_engine(trainer))
```


diff --git a/tests/ignite/contrib/handlers/test_trains_logger.py b/tests/ignite/contrib/handlers/test_trains_logger.py
index 0b9be046..aa5bbe82 100644
--- a/tests/ignite/contrib/handlers/test_trains_logger.py
+++ b/tests/ignite/contrib/handlers/test_trains_logger.py
@@ -1,5 +1,5 @@
 import math
-from unittest.mock import ANY, MagicMock, call
+from unittest.mock import ANY, MagicMock, Mock, call
 
 import pytest
 import torch
@@ -623,6 +623,7 @@ def test_trains_disk_saver_integration():
     to_save_serializable = {"model": model}
 
     mock_logger = MagicMock(spec=TrainsLogger)
+    trains.Task.current_task = Mock(return_value=object())
     trains_saver = TrainsSaver(mock_logger)
     trains.binding.frameworks.WeightsFileHandler.create_output_model = MagicMock()
 
@@ -634,3 +635,22 @@ def test_trains_disk_saver_integration():
     trainer.state.iteration = 1
     checkpoint(trainer)
     assert trains.binding.frameworks.WeightsFileHandler.create_output_model.call_count == 2
+
+
+def test_trains_disk_saver_integration_no_logger():
+    model = torch.nn.Module()
+    to_save_serializable = {"model": model}
+
+    trains.Task.current_task = Mock(return_value=object())
+    trains_saver = TrainsSaver()
+
+    trains.binding.frameworks.WeightsFileHandler.create_output_model = MagicMock()
+
+    checkpoint = Checkpoint(to_save=to_save_serializable, save_handler=trains_saver, n_saved=1)
+
+    trainer = Engine(lambda e, b: None)
+    trainer.state = State(epoch=0, iteration=0)
+    checkpoint(trainer)
+    trainer.state.iteration = 1
+    checkpoint(trainer)
+    assert trains.binding.frameworks.WeightsFileHandler.create_output_model.call_count == 2

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@cb9046ea6dc7f472c37f4413b771bbbcc18507ab#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/contrib/handlers/test_trains_logger.py::test_trains_disk_saver_integration_no_logger
tests/ignite/contrib/handlers/test_trains_logger.py::test_optimizer_params_handler_wrong_setup tests/ignite/contrib/handlers/test_trains_logger.py::test_optimizer_params tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_with_wrong_logger_type tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_output_transform tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_metric_names tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_both tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_with_wrong_global_step_transform_output tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_with_global_step_from_engine tests/ignite/contrib/handlers/test_trains_logger.py::test_output_handler_with_global_step_transform tests/ignite/contrib/handlers/test_trains_logger.py::test_weights_scalar_handler_wrong_setup tests/ignite/contrib/handlers/test_trains_logger.py::test_weights_scalar_handler tests/ignite/contrib/handlers/test_trains_logger.py::test_weights_scalar_handler_frozen_layers tests/ignite/contrib/handlers/test_trains_logger.py::test_weights_hist_handler_wrong_setup tests/ignite/contrib/handlers/test_trains_logger.py::test_weights_hist_handler tests/ignite/contrib/handlers/test_trains_logger.py::test_weights_hist_handler_frozen_layers tests/ignite/contrib/handlers/test_trains_logger.py::test_grads_scalar_handler_wrong_setup tests/ignite/contrib/handlers/test_trains_logger.py::test_grads_scalar_handler tests/ignite/contrib/handlers/test_trains_logger.py::test_grads_scalar_handler_frozen_layers tests/ignite/contrib/handlers/test_trains_logger.py::test_grads_hist_handler_wrong_setup tests/ignite/contrib/handlers/test_trains_logger.py::test_grads_hist_handler tests/ignite/contrib/handlers/test_trains_logger.py::test_grads_hist_frozen_layers tests/ignite/contrib/handlers/test_trains_logger.py::test_integration tests/ignite/contrib/handlers/test_trains_logger.py::test_integration_as_context_manager tests/ignite/contrib/handlers/test_trains_logger.py::test_trains_disk_saver_integration
ignite/contrib/handlers/trains_logger.py
ignite/contrib/handlers/trains_logger.py