import torch


def flatten(lst):
    """
    Flattens a list or iterable. Note that this chunk allocates more memory.

    Argument:
    lst (list or iteratble): input vector to be flattened

    Returns:
    one dimensional tensor with all elements of lst
    """
    tmp = [i.contiguous().view(-1, 1) for i in lst]
    return torch.cat(tmp).view(-1)