def gpu_no_of_var(var):
    """
    Function that returns the GPU number or whether the tensor is on GPU or not

    Args:
        var: torch tensor

    Returns:
        The CUDA device that the torch tensor is on, or whether the tensor is on GPU

    """

    try:
        is_cuda = next(var.parameters()).is_cuda
    except:
        is_cuda = var.is_cuda

    if is_cuda:
        try:
            return next(var.parameters()).get_device()
        except:
            return var.get_device()
    else:
        return False