import torch


def get_device(try_gpu=True, verbose=True):
    """Get a device to run your model on.

    It will try to get a GPU using CUDA by default. Otherwise, it wll get a CPU.
    """
    gpu_available = torch.cuda.is_available()
    device_name = "cuda" if (gpu_available and try_gpu) else "cpu"
    device = torch.device(device_name)
    if verbose: print(f"Using {device_name}")
    return device, device_name, gpu_available