def forward(self, inp, r, l, re_mask):
    NumRe = r.size(0)
    NumIn = l.size(0)
    relation = self.relation_emb(r)
    attn = torch.sum((relation * inp), 2)
    p = Variable(torch.cuda.FloatTensor(NumIn, NumRe).fill_(0.0))
    L = 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 = (L + l[i].data[0])
        if (R > L):
            Att = F.softmax(attn[:, L:R], 1)
            S[i] = self.dropout(torch.matmul(Att, inp[L:R]))
            R_vec[i] = relation[:, L, :]
        L = R
    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, r, l, re_mask):
    NumRe = r.size(0)
    NumIn = l.size(0)
    relation = self.relation_emb(r)
    attn = torch.sum((relation * inp), 2)
    p = Variable(torch.cuda.FloatTensor(NumIn, NumRe).fill_(0.0))
    L = 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 = (L + l[i].data[0])
        if (R > L):
            Att = F.softmax(attn[:, L:R], 1)
            S[i] = self.dropout(torch.matmul(Att, inp[L:R]))
            R_vec[i] = relation[:, L, :]
        L = R
    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)