(list_of_lists)
return flatten, offsets
making inputs to torch.nn.EmbeddingBag
making inputs to torch.nn.EmbeddingBag
making inputs to torch . nn . EmbeddingBag
def flatten_list_of_lists(list_of_lists):
    """
    making inputs to torch.nn.EmbeddingBag
    """
    list_of_lists = [[]] + list_of_lists
    offsets = np.cumsum([len(x) for x in list_of_lists])[:-1]
    flatten = sum(list_of_lists[1:], [])
    return flatten, offsets
def flatten_list_of_lists ( list_of_lists ) : list_of_lists = [ [ ] ] + list_of_lists offsets = np . cumsum ( [ len ( x ) for x in list_of_lists ] ) [ : - 1 ] flatten = sum ( list_of_lists [ 1 : ] , [ ] ) return flatten , offsets