def encode_title_to_id_lists(title_list, vocab, max_title_words):
    """
    Convert title words into word ids for Wikipedia and Abstract dataset.
    Args:
        title_list: a list of titles, each title is a list of lowercased string.
        vocab: vocabulary object to convert word into word ids
        max_title_words: int. If the length of title is greater than this limit, it will be truncated.
    Returns:
        title_inputs: a list of word ids, unpadded.
        title_lens: a list of int, indicating the length for each title.
    """
    title_inputs = []
    title_lens = []
    title_words = []

    for title in title_list:
        wids = []
        words = []
        for w in title:
            wid = vocab.word2id(w)
            if wid == vocab.unk_token:continue
            wids.append(wid)
            words.append(w)

        if len(wids) > max_title_words:
            wids = wids[:max_title_words]
            words = words[:max_title_words]
        title_inputs.append(wids)
        title_lens.append(len(wids))
        title_words.append(words)
    return title_inputs, title_lens, title_words