import torch


def nplist_to_tensor(nplist):
    """Concatenate a list of numpy vectors into one tensor.

    Args:
        nplist: a list of numpy vectors, e.g., direction loaded from h5 file.

    Returns:
        concatnated 1D tensor
    """
    v = []
    for d in nplist:
        w = torch.tensor(d).clone().detach()
        # Ignoreing the scalar values (w.dim() = 0).
        if w.dim() > 1:
            v.append(w.view(w.numel()))
        elif w.dim() == 1:
            v.append(w)
    return torch.cat(v)