def forward(self, inp_en, r_en, l_en, inp_zh, r_zh, l_zh, re_mask):
    NumRe = r_en.size(0)
    NumIn = l_zh.size(0)
    relation_en = self.relation_emb(r_en)
    relation_zh = self.relation_emb(r_zh)
    attn_en = torch.sum((relation_en * inp_en), 2)
    attn_zh = torch.sum((relation_zh * inp_zh), 2)
    p = Variable(torch.cuda.FloatTensor(NumIn, NumRe).fill_(0.0))
    L_en = 0
    L_zh = 0
    R_vec = Variable(torch.cuda.FloatTensor(NumIn, NumRe, Encodered_dim).fill_(0.0))
    S = Variable(torch.cuda.FloatTensor(NumIn, NumRe, Encodered_dim).fill_(0.0))
    for i in range(0, NumIn):
        R_en = (L_en + l_en[i].data[0])
        R_zh = (L_zh + l_zh[i].data[0])
        if ((R_en > L_en) and (R_zh > L_zh)):
            Att = F.softmax(torch.cat((attn_en[:, L_en:R_en], attn_zh[:, L_zh:R_zh]), 1), 1)
            S[i] = self.dropout(torch.matmul(Att, torch.cat((inp_en[L_en:R_en], inp_zh[L_zh:R_zh]), 0)))
            R_vec[i] = relation_en[:, L_en, :]
        elif (R_en > L_en):
            Att = F.softmax(attn_en[:, L_en:R_en], 1)
            S[i] = self.dropout(torch.matmul(Att, inp_en[L_en:R_en]))
            R_vec[i] = relation_en[:, L_en, :]
        elif (R_zh > L_zh):
            Att = F.softmax(attn_zh[:, L_zh:R_zh], 1)
            S[i] = self.dropout(torch.matmul(Att, inp_zh[L_zh:R_zh]))
            R_vec[i] = relation_zh[:, L_zh, :]
        else:
            print('ERR NO sentences')
            exit()
        L_en = R_en
        L_zh = R_zh
    p_n = F.log_softmax((self.M(S) + torch.sum((R_vec * S), 2).view(NumIn, NumRe, 1)), 2).view(NumIn, NumRe, dimR)
    return p_n[re_mask].view(NumIn, NumRe)
def forward(self, inp_en, r_en, l_en, inp_zh, r_zh, l_zh, re_mask):
    NumRe = r_en.size(0)
    NumIn = l_zh.size(0)
    relation_en = self.relation_emb(r_en)
    relation_zh = self.relation_emb(r_zh)
    attn_en = torch.sum((relation_en * inp_en), 2)
    attn_zh = torch.sum((relation_zh * inp_zh), 2)
    p = Variable(torch.cuda.FloatTensor(NumIn, NumRe).fill_(0.0))
    L_en = 0
    L_zh = 0
    R_vec = Variable(torch.cuda.FloatTensor(NumIn, NumRe, Encodered_dim).fill_(0.0))
    S = Variable(torch.cuda.FloatTensor(NumIn, NumRe, Encodered_dim).fill_(0.0))
    for i in range(0, NumIn):
        R_en = (L_en + l_en[i].data[0])
        R_zh = (L_zh + l_zh[i].data[0])
        if ((R_en > L_en) and (R_zh > L_zh)):
            Att = F.softmax(torch.cat((attn_en[:, L_en:R_en], attn_zh[:, L_zh:R_zh]), 1), 1)
            S[i] = self.dropout(torch.matmul(Att, torch.cat((inp_en[L_en:R_en], inp_zh[L_zh:R_zh]), 0)))
            R_vec[i] = relation_en[:, L_en, :]
        elif (R_en > L_en):
            Att = F.softmax(attn_en[:, L_en:R_en], 1)
            S[i] = self.dropout(torch.matmul(Att, inp_en[L_en:R_en]))
            R_vec[i] = relation_en[:, L_en, :]
        elif (R_zh > L_zh):
            Att = F.softmax(attn_zh[:, L_zh:R_zh], 1)
            S[i] = self.dropout(torch.matmul(Att, inp_zh[L_zh:R_zh]))
            R_vec[i] = relation_zh[:, L_zh, :]
        else:
            print('ERR NO sentences')
            exit()
        L_en = R_en
        L_zh = R_zh
    p_n = F.log_softmax((self.M(S) + torch.sum((R_vec * S), 2).view(NumIn, NumRe, 1)), 2).view(NumIn, NumRe, dimR)
    return p_n[re_mask].view(NumIn, NumRe)