def forward(self, src, trg, src_mask, trg_mask):
    (e_outputs, org_key, select) = self.encoder(src, src_mask)
    add_state = torch.tensor((decay2[:e_outputs.size(1)] + ([0] * max(0, (e_outputs.size(1) - 50))))).cuda().unsqueeze(0).unsqueeze((- 1))
    memory_bank = (e_outputs * add_state)
    (d_output, attn_weights) = ([], [])
    for i in range(1, (trg.size(1) + 1)):
        (word, attn, _) = self.decoder(trg[:, (i - 1)].unsqueeze(1), memory_bank, src_mask, trg_mask[:, (i - 1), (i - 1)].unsqueeze(1), step=(i - 1))
        d_output.append(word[:, (- 1)])
        attn_weights.append(attn[:, :, (- 1)].mean(dim=1))
        (memory_bank, add_state) = self.update_memory(memory_bank, add_state, e_outputs, attn_weights[(- 20):], d_output[(- 20):])
    output = self.logit(torch.cat([_.unsqueeze(1) for _ in d_output], 1))
    return (output, org_key, select)
def forward(self, src, trg, src_mask, trg_mask):
    (e_outputs, org_key, select) = self.encoder(src, src_mask)
    add_state = torch.tensor((decay2[:e_outputs.size(1)] + ([0] * max(0, (e_outputs.size(1) - 50))))).cuda().unsqueeze(0).unsqueeze((- 1))
    memory_bank = (e_outputs * add_state)
    (d_output, attn_weights) = ([], [])
    for i in range(1, (trg.size(1) + 1)):
        (word, attn, _) = self.decoder(trg[:, (i - 1)].unsqueeze(1), memory_bank, src_mask, trg_mask[:, (i - 1), (i - 1)].unsqueeze(1), step=(i - 1))
        d_output.append(word[:, (- 1)])
        attn_weights.append(attn[:, :, (- 1)].mean(dim=1))
        (memory_bank, add_state) = self.update_memory(memory_bank, add_state, e_outputs, attn_weights[(- 20):], d_output[(- 20):])
    output = self.logit(torch.cat([_.unsqueeze(1) for _ in d_output], 1))
    return (output, org_key, select)