import torch


def get_device(inputs):
    """ Get used device of a tensor or list of tensors. """
    if isinstance(inputs, torch.Tensor):
        device = inputs.device
    elif isinstance(inputs, (tuple, list)):
        device = inputs[0].device
    else:
        raise TypeError(f'Inputs can be a tensor or list of tensors, got {type(inputs)} instead!')
    return device