def get_device() -> torch.device:
    """Simple returning the best available device (TPU > GPU > CPU)."""
    device = torch.device("cpu")
    if SETTINGS.xla_required:
        device = xm.xla_device()
    elif torch.cuda.is_available():
        device = torch.device("cuda")
    return device
Simple returning the best available device (TPU > GPU > CPU).
catalyst/utils/torch.py