class_docstr: Encoder for Masked Language Modelling.
class_docstr_tok: ["Encoder","for","Masked","Language","Modelling","."]
code: def __init__(self, args, dictionary):
      super().__init__(dictionary)
  
      self.padding_idx = dictionary.pad()
      self.vocab_size = dictionary.__len__()
      self.max_positions = args.max_positions
  
      self.sentence_encoder = TransformerSentenceEncoder(
          padding_idx=self.padding_idx,
          vocab_size=self.vocab_size,
          num_encoder_layers=args.encoder_layers,
          embedding_dim=args.encoder_embed_dim,
          ffn_embedding_dim=args.encoder_ffn_embed_dim,
          num_attention_heads=args.encoder_attention_heads,
          dropout=args.dropout,
          attention_dropout=args.attention_dropout,
          activation_dropout=args.act_dropout,
          max_seq_len=self.max_positions,
          num_segments=args.num_segment,
          use_position_embeddings=not args.no_token_positional_embeddings,
          encoder_normalize_before=args.encoder_normalize_before,
          apply_bert_init=args.apply_bert_init,
          activation_fn=args.activation_fn,
          learned_pos_embedding=args.encoder_learned_pos,
      )
  
      self.share_input_output_embed = (
          args.share_encoder_input_output_embed
      )
      self.embed_out = None
      self.sentence_projection_layer = None
      self.sentence_out_dim = args.sentence_class_num
      self.lm_output_learned_bias = None
  
      # Remove head is set to true during fine-tuning
      self.load_softmax = not getattr(args, "remove_head", False)
  
      self.masked_lm_pooler = nn.Linear(
          args.encoder_embed_dim, args.encoder_embed_dim
      )
      self.pooler_activation = utils.get_activation_fn(
          args.pooler_activation_fn
      )
  
      self.lm_head_transform_weight = nn.Linear(
          args.encoder_embed_dim, args.encoder_embed_dim
      )
      self.activation_fn = utils.get_activation_fn(args.activation_fn)
      self.layer_norm = LayerNorm(args.encoder_embed_dim)
  
      self.lm_output_learned_bias = None
      if self.load_softmax:
          self.lm_output_learned_bias = nn.Parameter(
              torch.zeros(self.vocab_size)
          )
  
          if not self.share_input_output_embed:
              self.embed_out = nn.Linear(
                  args.encoder_embed_dim, self.vocab_size, bias=False
              )
  
          if args.sent_loss:
              self.sentence_projection_layer = nn.Linear(
                  args.encoder_embed_dim,
                  self.sentence_out_dim,
                  bias=False,
              )
  
imports: import logging
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderModel, register_model, register_model_architecture
  from fairseq.modules import LayerNorm, SinusoidalPositionalEmbedding, TransformerSentenceEncoder
  from fairseq.modules.transformer_sentence_encoder import init_bert_params
  from fairseq.utils import safe_hasattr
label_desc: Use image node_id 1 to create a new MaskedLMEncoder object from inherited base classes: FairseqEncoder with example: obj = MaskedLMEncoder(args, dictionary)