code: def _test_setup_logging(
      setup_logging_fn,
      kwargs_dict,
      output_handler_cls,
      opt_params_handler_cls,
      with_eval=True,
      with_optim=True,
      as_class=False,
      log_every_iters=1,
  ):
      trainer = Engine(lambda e, b: b)
      evaluators = None
      optimizers = None
  
      if with_eval:
          evaluator = Engine(lambda e, b: None)
          acc_scores = [
              0.1,
              0.2,
              0.3,
              0.4,
              0.3,
              0.3,
              0.2,
              0.1,
              0.1,
              0.0,
          ]
  
          @trainer.on(Events.EPOCH_COMPLETED)
          def validate(engine):
              evaluator.run([0, 1])
  
          @evaluator.on(Events.EPOCH_COMPLETED)
          def set_eval_metric(engine):
              engine.state.metrics = {
                  "acc": acc_scores[trainer.state.epoch - 1]
              }
  
          evaluators = {"validation": evaluator}
          if as_class:
              evaluators = evaluators["validation"]
  
      if with_optim:
          t = torch.tensor([0])
          optimizers = {"optimizer": torch.optim.SGD([t], lr=0.01)}
          if as_class:
              optimizers = optimizers["optimizer"]
  
      kwargs_dict["trainer"] = trainer
      kwargs_dict["optimizers"] = optimizers
      kwargs_dict["evaluators"] = evaluators
      kwargs_dict["log_every_iters"] = log_every_iters
  
      x_logger = setup_logging_fn(**kwargs_dict)
  
      handlers = trainer._event_handlers[Events.ITERATION_COMPLETED]
      for cls in [
          output_handler_cls,
      ]:
          assert any(
              [isinstance(h[0], cls) for h in handlers]
          ), f"{handlers}"
  
      if with_optim:
          handlers = trainer._event_handlers[Events.ITERATION_STARTED]
          for cls in [
              opt_params_handler_cls,
          ]:
              assert any(
                  [isinstance(h[0], cls) for h in handlers]
              ), f"{handlers}"
  
      if with_eval:
          handlers = evaluator._event_handlers[Events.COMPLETED]
          for cls in [
              output_handler_cls,
          ]:
              assert any(
                  [isinstance(h[0], cls) for h in handlers]
              ), f"{handlers}"
  
      data = [0, 1, 2]
      trainer.run(data, max_epochs=10)
  
      if "output_path" in kwargs_dict:
          tb_files = list(os.listdir(kwargs_dict["output_path"]))
          assert len(tb_files) == 1
          for v in [
              "events",
          ]:
              assert any([v in c for c in tb_files]), f"{tb_files}"
  
      return x_logger
  
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 12 for calling a global function with example usage: _test_setup_logging(setup_logging_fn, kwargs_dict, output_handler_cls, opt_params_handler_cls, with_eval, with_optim, as_class, log_every_iters) and returns: x_logger