def encodeMLM(self, src_tokens, src_lengths, bert_encoder_out):
    "\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        "
    self.src_tokens = src_tokens
    x = (self.embed_scale * self.embed_tokens(src_tokens))
    '\n        ratio = 0.3\n        mask = np.random.choice(src_tokens.size()[1], (int(src_tokens.size()[1] * ratio), ),replace = False)\n        \n        \n        if mask is not None:\n        '
    '\n        if x.size(1)<10:\n            mask = [4]\n        else:\n            mask = [7,9]\n        x[:, mask] = self.mask_embedding\n         \n        '
    mask_output = self.mask(src_tokens, x)
    p = mask_output
    p = p
    t_p = torch.argsort(p, dim=1)
    ratio = 0.2
    self.ratio = ratio
    p_mask = torch.where((t_p < (t_p.size(1) * ratio)), torch.zeros_like(p), torch.ones_like(p))
    self.p_mask = p_mask
    p_mask = p_mask.unsqueeze((- 1))
    self.mask_output = p
    x = (x * p_mask.detach())
    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, bert_encoder_out['bert_encoder_out'], bert_encoder_out['bert_encoder_padding_mask'])
    if self.layer_norm:
        x = self.layer_norm(x)
    encoder_vocab_output = self.output_vocab_linear(x)
    self.encoder_vocab_output2 = torch.nn.functional.softmax(encoder_vocab_output, dim=(- 1))
    self.token = src_tokens
    return encoder_vocab_output
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 encodeMLM(self, src_tokens, src_lengths, bert_encoder_out):
    "\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        "
    self.src_tokens = src_tokens
    x = (self.embed_scale * self.embed_tokens(src_tokens))
    '\n        ratio = 0.3\n        mask = np.random.choice(src_tokens.size()[1], (int(src_tokens.size()[1] * ratio), ),replace = False)\n        \n        \n        if mask is not None:\n        '
    '\n        if x.size(1)<10:\n            mask = [4]\n        else:\n            mask = [7,9]\n        x[:, mask] = self.mask_embedding\n         \n        '
    mask_output = self.mask(src_tokens, x)
    p = mask_output
    p = p
    t_p = torch.argsort(p, dim=1)
    ratio = 0.2
    self.ratio = ratio
    p_mask = torch.where((t_p < (t_p.size(1) * ratio)), torch.zeros_like(p), torch.ones_like(p))
    self.p_mask = p_mask
    p_mask = p_mask.unsqueeze((- 1))
    self.mask_output = p
    x = (x * p_mask.detach())
    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, bert_encoder_out['bert_encoder_out'], bert_encoder_out['bert_encoder_padding_mask'])
    if self.layer_norm:
        x = self.layer_norm(x)
    encoder_vocab_output = self.output_vocab_linear(x)
    self.encoder_vocab_output2 = torch.nn.functional.softmax(encoder_vocab_output, dim=(- 1))
    self.token = src_tokens
    return encoder_vocab_output