def forward(self, src_tokens, src_lengths):
    "\n        Args:\n            src_tokens (LongTensor): tokens in the source language of shape\n                `(batch, src_len)`\n            src_lengths (torch.LongTensor): lengths of each source sentence of\n                shape `(batch)`\n\n        Returns:\n            dict:\n                - **encoder_out** (Tensor): the last encoder layer's output of\n                  shape `(src_len, batch, embed_dim)`\n                - **encoder_padding_mask** (ByteTensor): the positions of\n                  padding elements of shape `(batch, src_len)`\n        "
    x = (self.embed_scale * self.embed_tokens(src_tokens))
    if (self.embed_positions is not None):
        x += self.embed_positions(src_tokens)
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = x.transpose(0, 1)
    encoder_padding_mask = src_tokens.eq(self.padding_idx)
    if (not encoder_padding_mask.any()):
        encoder_padding_mask = None
    for layer in self.layers:
        x = layer(x, encoder_padding_mask)
    if self.layer_norm:
        x = self.layer_norm(x)
    return {'encoder_out': x, 'encoder_padding_mask': encoder_padding_mask}
Args:
    src_tokens (LongTensor): tokens in the source language of shape
        `(batch, src_len)`
    src_lengths (torch.LongTensor): lengths of each source sentence of
        shape `(batch)`

Returns:
    dict:
        - **encoder_out** (Tensor): the last encoder layer's output of
          shape `(src_len, batch, embed_dim)`
        - **encoder_padding_mask** (ByteTensor): the positions of
          padding elements of shape `(batch, src_len)`
def forward(self, src_tokens, src_lengths):
    "\n        Args:\n            src_tokens (LongTensor): tokens in the source language of shape\n                `(batch, src_len)`\n            src_lengths (torch.LongTensor): lengths of each source sentence of\n                shape `(batch)`\n\n        Returns:\n            dict:\n                - **encoder_out** (Tensor): the last encoder layer's output of\n                  shape `(src_len, batch, embed_dim)`\n                - **encoder_padding_mask** (ByteTensor): the positions of\n                  padding elements of shape `(batch, src_len)`\n        "
    x = (self.embed_scale * self.embed_tokens(src_tokens))
    if (self.embed_positions is not None):
        x += self.embed_positions(src_tokens)
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = x.transpose(0, 1)
    encoder_padding_mask = src_tokens.eq(self.padding_idx)
    if (not encoder_padding_mask.any()):
        encoder_padding_mask = None
    for layer in self.layers:
        x = layer(x, encoder_padding_mask)
    if self.layer_norm:
        x = self.layer_norm(x)
    return {'encoder_out': x, 'encoder_padding_mask': encoder_padding_mask}