(words, w2i, no_BE=False)
return w2i_l, l
Input: [ ['I', 'am', 'hero'],
             ['You', 'are 'geneus'] ]
    output:

    w2i =  [ B x max_seq_len, 1]
    wemb = [B x max_seq_len, dim]

    - Zero-padded when word is not available (teated as <UNK>)
Input: [ ['I', 'am', 'hero'],
             ['You', 'are 'geneus'] ]
    output:
Input : [ [ I am hero ] [ You are geneus ] ] output :
def words_to_idx(words, w2i, no_BE=False):
    """
    Input: [ ['I', 'am', 'hero'],
             ['You', 'are 'geneus'] ]
    output:

    w2i =  [ B x max_seq_len, 1]
    wemb = [B x max_seq_len, dim]

    - Zero-padded when word is not available (teated as <UNK>)
    """
    bS = len(words)
    l = torch.zeros(bS, dtype=torch.long).to(device) # length of the seq. of words.
    w2i_l_list = [] # shall be replaced to arr

    #     wemb_NLq_batch = []

    for i, words1 in enumerate(words):

        w2i_l1, l1 = word_to_idx1(words1, w2i, no_BE)
        w2i_l_list.append(w2i_l1)
        l[i] = l1

    # Prepare tensor of wemb
    # overwrite w2i_l
    w2i_l = torch.zeros([bS, int(max(l))], dtype=torch.long).to(device)
    for b in range(bS):
        w2i_l[b, :l[b]] = torch.LongTensor(w2i_l_list[b]).to(device)

    return w2i_l, l
def words_to_idx ( words , w2i , no_BE = False ) : bS = len ( words ) l = torch . zeros ( bS , dtype = torch . long ) . to ( device ) # length of the seq. of words. w2i_l_list = [ ] # shall be replaced to arr #     wemb_NLq_batch = [] for i , words1 in enumerate ( words ) : w2i_l1 , l1 = word_to_idx1 ( words1 , w2i , no_BE ) w2i_l_list . append ( w2i_l1 ) l [ i ] = l1 # Prepare tensor of wemb # overwrite w2i_l w2i_l = torch . zeros ( [ bS , int ( max ( l ) ) ] , dtype = torch . long ) . to ( device ) for b in range ( bS ) : w2i_l [ b , : l [ b ] ] = torch . LongTensor ( w2i_l_list [ b ] ) . to ( device ) return w2i_l , l