def forward(self, input, encoder_state, incr_state=None):
    (encoder_output, encoder_mask) = encoder_state
    seq_len = input.size(1)
    positions = input.new(seq_len).long()
    positions = torch.arange(seq_len, out=positions).unsqueeze(0)
    tensor = self.embeddings(input)
    if self.embeddings_scale:
        tensor = (tensor * np.sqrt(self.dim))
    tensor = (tensor + self.position_embeddings(positions).expand_as(tensor))
    for layer in self.layers:
        tensor = layer(tensor, encoder_output, encoder_mask)
    return (tensor, None)
def forward(self, input, encoder_state, incr_state=None):
    (encoder_output, encoder_mask) = encoder_state
    seq_len = input.size(1)
    positions = input.new(seq_len).long()
    positions = torch.arange(seq_len, out=positions).unsqueeze(0)
    tensor = self.embeddings(input)
    if self.embeddings_scale:
        tensor = (tensor * np.sqrt(self.dim))
    tensor = (tensor + self.position_embeddings(positions).expand_as(tensor))
    for layer in self.layers:
        tensor = layer(tensor, encoder_output, encoder_mask)
    return (tensor, None)