code: def test_setup_common_training_handlers(dirname, capsys):
      _test_setup_common_training_handlers(dirname, device="cpu")
  
      # Check epoch-wise pbar
      captured = capsys.readouterr()
      out = captured.err.split("\r")
      out = list(map(lambda x: x.strip(), out))
      out = list(filter(None, out))
      assert (
          "Epoch" in out[-1] or "Epoch" in out[-2]
      ), f"{out[-2]}, {out[-1]}"
  
      _test_setup_common_training_handlers(
          dirname, device="cpu", output_transform=lambda loss: [loss]
      )
  
      # Check epoch-wise pbar
      captured = capsys.readouterr()
      out = captured.err.split("\r")
      out = list(map(lambda x: x.strip(), out))
      out = list(filter(None, out))
      assert (
          "Epoch" in out[-1] or "Epoch" in out[-2]
      ), f"{out[-2]}, {out[-1]}"
  
      _test_setup_common_training_handlers(
          dirname,
          device="cpu",
          output_transform=lambda loss: {"batch_loss": loss},
      )
  
      # Check epoch-wise pbar
      captured = capsys.readouterr()
      out = captured.err.split("\r")
      out = list(map(lambda x: x.strip(), out))
      out = list(filter(None, out))
      assert (
          "Epoch" in out[-1] or "Epoch" in out[-2]
      ), f"{out[-2]}, {out[-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 5 for calling a global function with example usage: test_setup_common_training_handlers(dirname, capsys) without return types