code: def _setup_logging(
      logger: BaseLogger,
      trainer: Engine,
      optimizers: Optional[
          Union[Optimizer, Dict[str, Optimizer], Dict[None, Optimizer]]
      ],
      evaluators: Optional[Union[Engine, Dict[str, Engine]]],
      log_every_iters: int,
  ) -> None:
      if optimizers is not None:
          if not isinstance(optimizers, (Optimizer, Mapping)):
              raise TypeError(
                  "Argument optimizers should be either a single optimizer or a dictionary or optimizers"
              )
  
      if evaluators is not None:
          if not isinstance(evaluators, (Engine, Mapping)):
              raise TypeError(
                  "Argument evaluators should be either a single engine or a dictionary or engines"
              )
  
      if log_every_iters is None:
          log_every_iters = 1
  
      logger.attach_output_handler(
          trainer,
          event_name=Events.ITERATION_COMPLETED(every=log_every_iters),
          tag="training",
          metric_names="all",
      )
  
      if optimizers is not None:
          # Log optimizer parameters
          if isinstance(optimizers, Optimizer):
              optimizers = {None: optimizers}
  
          for k, optimizer in optimizers.items():
              logger.attach_opt_params_handler(
                  trainer,
                  Events.ITERATION_STARTED(every=log_every_iters),
                  optimizer,
                  param_name="lr",
                  tag=k,
              )
  
      if evaluators is not None:
          # Log evaluation metrics
          if isinstance(evaluators, Engine):
              evaluators = {"validation": evaluators}
  
          event_name = (
              Events.ITERATION_COMPLETED
              if isinstance(logger, WandBLogger)
              else None
          )
          gst = global_step_from_engine(
              trainer, custom_event_name=event_name
          )
          for k, evaluator in evaluators.items():
              logger.attach_output_handler(
                  evaluator,
                  event_name=Events.COMPLETED,
                  tag=k,
                  metric_names="all",
                  global_step_transform=gst,
              )
  
imports: import numbers
  import warnings
  from functools import partial
  from typing import Any, Callable, cast, Dict, Iterable, Mapping, Optional, Sequence, Union
  import torch
  import torch.nn
  from torch.optim.optimizer import Optimizer
  from torch.utils.data.distributed import DistributedSampler
  import ignite.distributed
  from ignite.contrib.handlers import ClearMLLogger, global_step_from_engine, MLflowLogger, NeptuneLogger, PolyaxonLogger, ProgressBar, TensorboardLogger, VisdomLogger, WandBLogger
  from ignite.contrib.handlers.base_logger import BaseLogger
  from ignite.contrib.metrics import GpuInfo
  from ignite.engine import Engine, Events
  from ignite.handlers import Checkpoint, DiskSaver, EarlyStopping, TerminateOnNan
  from ignite.handlers.checkpoint import BaseSaveHandler
  from ignite.handlers.param_scheduler import ParamScheduler
  from ignite.metrics import RunningAverage
  from ignite.metrics.metric import RunningBatchWise
  from ignite.utils import deprecated
label_desc: Use image node_id 6 for calling a global function with example usage: _setup_logging(logger, trainer, optimizers, evaluators, log_every_iters) without return types