import torch


def determine_device(gpu_selected):
    """ Determines the device to be used based on requested device and available device

    :param gpu_selected: boolean value provided by the user
    :return: device to be used based on choice and availability
    """
    if gpu_selected and torch.cuda.is_available():
        device = "cuda"
    else:
        device = "cpu"
        if gpu_selected: print("WARN: CUDA is not available. Using CPU instead")

    return device