(i_hds, l_hs, hS, all_encoder_layer, col_pool_type='start_tok')
return wemb_h
As if
    [ [table-1-col-1-tok1, t1-c1-t2, ...],
       [t1-c2-t1, t1-c2-t2, ...].
       ...
       [t2-c1-t1, ...,]
    ]

    # i_hds = [ [  Batch 1 ] [  Batch 2  ] ]
    #  [Batch 1] = [ (col1_st_idx, col1_ed_idx), (col2_st_idx, col2_ed_idx), ...]
    # i_hds = [[(11, 14), (15, 19), (20, 21), (22, 24), (25, 27), (28, 29)],
            #  [(16, 19), (20, 24), (25, 26), (27, 29), (30, 32), (33, 34)]]

    pool_type = 'start_tok', 'end_tok', 'avg'
As if
    [ [table-1-col-1-tok1, t1-c1-t2, ...],
       [t1-c2-t1, t1-c2-t2, ...].
       ...
       [t2-c1-t1, ...,]
    ]
As if [ [ table - 1 - col - 1 - tok1 t1 - c1 - t2 ... ] [ t1 - c2 - t1 t1 - c2 - t2 ... ] . ... [ t2 - c1 - t1 ... ] ]
def get_wemb_h_FT_Scalar_1(i_hds, l_hs, hS, all_encoder_layer, col_pool_type='start_tok'):
    """
    As if
    [ [table-1-col-1-tok1, t1-c1-t2, ...],
       [t1-c2-t1, t1-c2-t2, ...].
       ...
       [t2-c1-t1, ...,]
    ]

    # i_hds = [ [  Batch 1 ] [  Batch 2  ] ]
    #  [Batch 1] = [ (col1_st_idx, col1_ed_idx), (col2_st_idx, col2_ed_idx), ...]
    # i_hds = [[(11, 14), (15, 19), (20, 21), (22, 24), (25, 27), (28, 29)],
            #  [(16, 19), (20, 24), (25, 26), (27, 29), (30, 32), (33, 34)]]

    pool_type = 'start_tok', 'end_tok', 'avg'

    """
    bS = len(l_hs)
    l_hs_max = max(l_hs)
    wemb_h = torch.zeros([bS, l_hs_max, hS]).to(device)
    for b, i_hds1 in enumerate(i_hds):
        for i_hd, st_ed_pair in enumerate(i_hds1):
            st, ed = st_ed_pair
            if col_pool_type == 'start_tok':
                vec = all_encoder_layer[-1][b, st,:]
            elif col_pool_type == 'end_tok':
                vec = all_encoder_layer[-1][b, ed, :]
            elif col_pool_type == 'avg':
                vecs = all_encoder_layer[-1][b, st:ed,:]
                vec = vecs.mean(dim=1, keepdim=True)
            else:
                raise ValueError
            wemb_h[b, i_hd, :] = vec

    return wemb_h
def get_wemb_h_FT_Scalar_1 ( i_hds , l_hs , hS , all_encoder_layer , col_pool_type = 'start_tok' ) : bS = len ( l_hs ) l_hs_max = max ( l_hs ) wemb_h = torch . zeros ( [ bS , l_hs_max , hS ] ) . to ( device ) for b , i_hds1 in enumerate ( i_hds ) : for i_hd , st_ed_pair in enumerate ( i_hds1 ) : st , ed = st_ed_pair if col_pool_type == 'start_tok' : vec = all_encoder_layer [ - 1 ] [ b , st , : ] elif col_pool_type == 'end_tok' : vec = all_encoder_layer [ - 1 ] [ b , ed , : ] elif col_pool_type == 'avg' : vecs = all_encoder_layer [ - 1 ] [ b , st : ed , : ] vec = vecs . mean ( dim = 1 , keepdim = True ) else : raise ValueError wemb_h [ b , i_hd , : ] = vec return wemb_h