def encode_phrase_bank_to_id_lists(phrase_bank_list, vocab, max_bank_size):
    """Encode keyphrase bank into word ids.

    Args:
         phrase_bank_list (list): the list of keyphrase bank for each trianing data, each list
            is a list of keyphrase (already deduplicated), each keyphrase is a string.
         vocab (Vocab): vocabulary to convert words into ids
         max_bank_size (int): maximum allowed number of keyphrase per instance.
    Returns:
        phrase_bank_word_ids (list): the list of phrase bank word ids
        phrase_bank_words (list): the list of tokenized phrase words, with the same
            dimension as phrase_bank_word_ids
    """
    phrase_bank_word_ids = []
    phrase_bank_words = []

    for sample in phrase_bank_list:
        cur_ph_bank_wids = []
        cur_ph_bank_words = []
        for ph in sample:
            ph = ph.lower()
            cur_ph = []
            cur_ph_ids = []
            for w in ph.split():
                if w in vocab._word2id:
                    cur_ph.append(w)
                    cur_ph_ids.append(vocab.word2id(w))
            if len(cur_ph_ids) == 0: continue
            cur_ph_bank_wids.append(cur_ph_ids)
            cur_ph_bank_words.append(cur_ph)
            if len(cur_ph_bank_wids) == max_bank_size:
                break

        phrase_bank_word_ids.append(cur_ph_bank_wids)
        phrase_bank_words.append(cur_ph_bank_words)

    return phrase_bank_word_ids, phrase_bank_words