import torch


def select_device(device: str = "") -> torch.device:
    """Select device where model and image will be allocated on

    Args:
        device (str, optional): name of device (cpu, cuda, ..). Defaults to "".

    Returns:
        device (torch.device): selected device
    """
    if not isinstance(device, str):
        device = device.type
    cpu = device.lower() == "cpu"
    cuda = not cpu and torch.cuda.is_available()
    return torch.device("cuda:0" if cuda else "cpu")