code: def resolve_device(
      device: Union[str, torch.device]
  ) -> Union[str, torch.device]:
      """
      Resolves a torch device to the most appropriate one.
  
      The ``"auto"`` device is resolved to ``"cuda"`` if CUDA is available,
      and to ``"cpu"`` otherwise. Otherwise the device is unchanged.
      """
      if device == "auto":
          if torch.cuda.is_available():
              return "cuda"
          return "cpu"
  
      return device
  
file_path: gluonts/src/gluonts/torch/util.py
imports: from typing import List, Optional, Type, Union
  import inspect
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: resolve_device(device) and returns: device, str, str