(g_wvi, mL_w, mL_nt)
return pnt_n, l_g_wvi
Generate one-hot idx indicating vectors with their lenghts.

    :param g_wvi: e.g. [[[0, 6, 7, 8, 15], [0, 1, 2, 3, 4, 15]], [[0, 1, 2, 3, 16], [0, 7, 8, 9, 16]]]
    where_val idx in nlu_t. 0 = <BEG>, -1 = <END>.
    :param mL_w: 4
    :param mL_nt: 200
    :return:
Generate one-hot idx indicating vectors with their lenghts.
Generate one - hot idx indicating vectors with their lenghts .
def gen_pnt_n(g_wvi, mL_w, mL_nt):
    """
    Generate one-hot idx indicating vectors with their lenghts.

    :param g_wvi: e.g. [[[0, 6, 7, 8, 15], [0, 1, 2, 3, 4, 15]], [[0, 1, 2, 3, 16], [0, 7, 8, 9, 16]]]
    where_val idx in nlu_t. 0 = <BEG>, -1 = <END>.
    :param mL_w: 4
    :param mL_nt: 200
    :return:
    """
    bS = len(g_wvi)
    for g_wvi1 in g_wvi:
        for g_wvi11 in g_wvi1:
            l11 = len(g_wvi11)

    mL_g_wvi = max([max([0] + [len(tok) for tok in gwsi]) for gwsi in g_wvi]) - 1
    # zero because of '' case.
    # -1 because we already have <BEG>
    if mL_g_wvi < 1:
        mL_g_wvi = 1
    # NLq_token_pos = torch.zeros(bS, 5 - 1, mL_g_wvi, self.max_NLq_token_num)

    # l_g_wvi = torch.zeros(bS, 5 - 1)
    pnt_n = torch.zeros(bS, mL_w, mL_g_wvi, mL_nt).to(device) # one hot
    l_g_wvi = torch.zeros(bS, mL_w).to(device)

    for b, g_wvi1 in enumerate(g_wvi):
        i_wn = 0  # To prevent error from zero number of condition.
        for i_wn, g_wvi11 in enumerate(g_wvi1):
            # g_wvi11: [0, where_conds pos in NLq, end]
            g_wvi11_n1 = g_wvi11[:-1]  # doesn't count <END> idx.
            l_g_wvi[b, i_wn] = len(g_wvi11_n1)
            for t, idx in enumerate(g_wvi11_n1):
                pnt_n[b, i_wn, t, idx] = 1

            # Pad
        if i_wn < (mL_w - 1):  # maximum number of conidtions is 4
            pnt_n[b, i_wn + 1:, 0, 1] = 1  # # cannot understand... [<BEG>, <END>]??
            l_g_wvi[b, i_wn + 1:] = 1  # it means there is only <BEG>.


    return pnt_n, l_g_wvi
def gen_pnt_n ( g_wvi , mL_w , mL_nt ) : bS = len ( g_wvi ) for g_wvi1 in g_wvi : for g_wvi11 in g_wvi1 : l11 = len ( g_wvi11 ) mL_g_wvi = max ( [ max ( [ 0 ] + [ len ( tok ) for tok in gwsi ] ) for gwsi in g_wvi ] ) - 1 # zero because of '' case. # -1 because we already have <BEG> if mL_g_wvi < 1 : mL_g_wvi = 1 # NLq_token_pos = torch.zeros(bS, 5 - 1, mL_g_wvi, self.max_NLq_token_num) # l_g_wvi = torch.zeros(bS, 5 - 1) pnt_n = torch . zeros ( bS , mL_w , mL_g_wvi , mL_nt ) . to ( device ) # one hot l_g_wvi = torch . zeros ( bS , mL_w ) . to ( device ) for b , g_wvi1 in enumerate ( g_wvi ) : i_wn = 0 # To prevent error from zero number of condition. for i_wn , g_wvi11 in enumerate ( g_wvi1 ) : # g_wvi11: [0, where_conds pos in NLq, end] g_wvi11_n1 = g_wvi11 [ : - 1 ] # doesn't count <END> idx. l_g_wvi [ b , i_wn ] = len ( g_wvi11_n1 ) for t , idx in enumerate ( g_wvi11_n1 ) : pnt_n [ b , i_wn , t , idx ] = 1 # Pad if i_wn < ( mL_w - 1 ) : # maximum number of conidtions is 4 pnt_n [ b , i_wn + 1 : , 0 , 1 ] = 1 # # cannot understand... [<BEG>, <END>]?? l_g_wvi [ b , i_wn + 1 : ] = 1 # it means there is only <BEG>. return pnt_n , l_g_wvi