code: def test_asserts_setup_common_training_handlers():
      trainer = Engine(lambda e, b: None)
  
      with pytest.raises(
          ValueError,
          match=r"If to_save argument is provided then output_path or save_handler arguments should be also defined",
      ):
          setup_common_training_handlers(trainer, to_save={})
  
      with pytest.raises(
          ValueError,
          match=r"Arguments output_path and save_handler are mutually exclusive",
      ):
          setup_common_training_handlers(
              trainer,
              to_save={},
              output_path="abc",
              save_handler=lambda c, f, m: None,
          )
  
      with pytest.warns(
          UserWarning,
          match=r"Argument train_sampler is a distributed sampler",
      ):
          train_sampler = MagicMock(spec=DistributedSampler)
          setup_common_training_handlers(
              trainer, train_sampler=train_sampler
          )
  
      if not torch.cuda.is_available():
          with pytest.raises(
              RuntimeError,
              match=r"This contrib module requires available GPU",
          ):
              setup_common_training_handlers(
                  trainer, with_gpu_stats=True
              )
  
      with pytest.raises(
          TypeError,
          match=r"Unhandled type of update_function's output.",
      ):
          trainer = Engine(lambda e, b: None)
          setup_common_training_handlers(
              trainer,
              output_names=["loss"],
              with_pbar_on_iters=False,
              with_pbars=False,
              with_gpu_stats=False,
              stop_on_nan=False,
              clear_cuda_cache=False,
          )
          trainer.run([1])
  
imports: import os
  import sys
  from unittest.mock import call, MagicMock
  import pytest
  import torch
  import torch.nn
  from torch.utils.data.distributed import DistributedSampler
  import ignite.contrib.handlers
  import ignite.distributed
  from ignite.contrib.engines.common import _setup_logging, add_early_stopping_by_val_score, gen_save_best_models_by_val_score, save_best_model_by_val_score, setup_any_logging, setup_clearml_logging, setup_common_training_handlers, setup_mlflow_logging, setup_neptune_logging, setup_plx_logging, setup_tb_logging, setup_trains_logging, setup_visdom_logging, setup_wandb_logging
  from ignite.engine import Engine, Events
  from ignite.handlers import DiskSaver, TerminateOnNan
label_desc: Use image node_id 2 for calling a global function with example usage: test_asserts_setup_common_training_handlers() without return types