code: def _check_arg(
      on_tpu: bool,
      on_mps: bool,
      amp_mode: Optional[str],
      scaler: Optional[Union[bool, "torch.cuda.amp.GradScaler"]],
  ) -> Tuple[Optional[str], Optional["torch.cuda.amp.GradScaler"]]:
      """Checking tpu, mps, amp and GradScaler instance combinations."""
      if on_mps and amp_mode:
          raise ValueError(
              "amp_mode cannot be used with mps device. Consider using amp_mode=None or device='cuda'."
          )
  
      if on_tpu and not idist.has_xla_support:
          raise RuntimeError(
              "In order to run on TPU, please install PyTorch XLA"
          )
  
      if amp_mode and on_tpu:
          raise ValueError(
              "amp_mode cannot be used with xla device. Consider using amp_mode=None or device='cuda'."
          )
  
      if scaler:
          if amp_mode != "amp":
              raise ValueError(
                  f"scaler argument is {scaler}, but amp_mode is {amp_mode}. Consider using amp_mode='amp'."
              )
          elif amp_mode == "amp" and isinstance(scaler, bool):
              try:
                  from torch.cuda.amp import GradScaler
              except ImportError:
                  raise ImportError(
                      "Please install torch>=1.6.0 to use scaler argument."
                  )
              scaler = GradScaler(enabled=True)
  
      if on_tpu:
          return "tpu", None
      elif scaler and amp_mode == "amp":
          return amp_mode, scaler  # type: ignore[return-value]
      else:
          return amp_mode, None
  
file_path: ignite/ignite/engine/__init__.py
imports: from collections.abc import Mapping
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union
  import torch
  import ignite.distributed
  from ignite.engine.deterministic import DeterministicEngine
  from ignite.engine.engine import Engine
  from ignite.engine.events import CallableEventWithFilter, EventEnum, Events, EventsList, RemovableEventHandle, State
  from ignite.metrics import Metric
  from ignite.utils import convert_tensor
label_desc: Use image node_id 6 for calling a global function with example usage: _check_arg(on_tpu, on_mps, amp_mode, scaler) and returns: str,  None, amp_mode,  scaler, amp_mode,  None