class_docstr: Class for training a Masked Language Model. It also supports an
  additional sentence level prediction if the sent-loss argument is set.
class_docstr_tok: ["Class","for","training","a","Masked","Language","Model",".","It","also","supports","an","additional","sentence","level","prediction","if","the","sent-loss","argument","is","set","."]
docstr: Add model-specific arguments to the parser.
docstr_tok: ["Add","model-specific","arguments","to","the","parser","."]
code: def add_args(parser):
      """Add model-specific arguments to the parser."""
      # Arguments related to dropout
      parser.add_argument(
          "--dropout",
          type=float,
          metavar="D",
          help="dropout probability",
      )
      parser.add_argument(
          "--attention-dropout",
          type=float,
          metavar="D",
          help="dropout probability for" " attention weights",
      )
      parser.add_argument(
          "--act-dropout",
          type=float,
          metavar="D",
          help="dropout probability after" " activation in FFN",
      )
  
      # Arguments related to hidden states and self-attention
      parser.add_argument(
          "--encoder-ffn-embed-dim",
          type=int,
          metavar="N",
          help="encoder embedding dimension for FFN",
      )
      parser.add_argument(
          "--encoder-layers",
          type=int,
          metavar="N",
          help="num encoder layers",
      )
      parser.add_argument(
          "--encoder-attention-heads",
          type=int,
          metavar="N",
          help="num encoder attention heads",
      )
  
      # Arguments related to input and output embeddings
      parser.add_argument(
          "--encoder-embed-dim",
          type=int,
          metavar="N",
          help="encoder embedding dimension",
      )
      parser.add_argument(
          "--share-encoder-input-output-embed",
          action="store_true",
          help="share encoder input" " and output embeddings",
      )
      parser.add_argument(
          "--encoder-learned-pos",
          action="store_true",
          help="use learned positional embeddings in the encoder",
      )
      parser.add_argument(
          "--no-token-positional-embeddings",
          action="store_true",
          help="if set, disables positional embeddings"
          " (outside self attention)",
      )
      parser.add_argument(
          "--num-segment",
          type=int,
          metavar="N",
          help="num segment in the input",
      )
      parser.add_argument(
          "--max-positions",
          type=int,
          help="number of positional embeddings to learn",
      )
  
      # Arguments related to sentence level prediction
      parser.add_argument(
          "--sentence-class-num",
          type=int,
          metavar="N",
          help="number of classes for sentence task",
      )
      parser.add_argument(
          "--sent-loss",
          action="store_true",
          help="if set," " calculate sentence level predictions",
      )
  
      # Arguments related to parameter initialization
      parser.add_argument(
          "--apply-bert-init",
          action="store_true",
          help="use custom param initialization for BERT",
      )
  
      # misc params
      parser.add_argument(
          "--activation-fn",
          choices=utils.get_available_activation_fns(),
          help="activation function to use",
      )
      parser.add_argument(
          "--pooler-activation-fn",
          choices=utils.get_available_activation_fns(),
          help="Which activation function to use for pooler layer.",
      )
      parser.add_argument(
          "--encoder-normalize-before",
          action="store_true",
          help="apply layernorm before each encoder block",
      )
  
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 2 for calling the MaskedLMModel obj's underlying member method code with example usage: obj.add_args(parser) without return types