class_docstr: Adapted Transformer model (https://arxiv.org/abs/1706.03762) for
  speech-to-text tasks. The Transformer encoder/decoder remains the same.
  A trainable input subsampler is prepended to the Transformer encoder to
  project inputs into the encoder dimension as well as downsample input
  sequence for computational efficiency.
class_docstr_tok: ["Adapted","Transformer","model","(","https",":","\/\/arxiv.org\/abs\/1706.03762",")","for","speech-to-text","tasks",".","The","Transformer","encoder\/decoder","remains","the","same",".","A","trainable","input","subsampler","is","prepended","to","the","Transformer","encoder","to","project","inputs","into","the","encoder","dimension","as","well","as","downsample","input","sequence","for","computational","efficiency","."]
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."""
      # input
      parser.add_argument(
          "--conv-kernel-sizes",
          type=str,
          metavar="STR",
          help="kernel sizes of Conv1d (s2t_transformer) subsampling layers",
      )
      parser.add_argument(
          "--conv-channels",
          type=int,
          metavar="N",
          help="# of channels in Conv1d (s2t_transformer) subsampling layers",
      )
      parser.add_argument(
          "--conv-out-channels",
          type=int,
          metavar="N",
          help="# of channels in Conv2d (convtransformer) subsampling layers",
      )
      parser.add_argument(
          "--conv-version",
          type=str,
          default="s2t_transformer",
          choices=["s2t_transformer", "convtransformer"],
          help="version of frontend convolutional layers",
      )
      # Transformer
      parser.add_argument(
          "--activation-fn",
          type=str,
          default="relu",
          choices=utils.get_available_activation_fns(),
          help="activation function to use",
      )
      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(
          "--activation-dropout",
          "--relu-dropout",
          type=float,
          metavar="D",
          help="dropout probability after activation in FFN.",
      )
      parser.add_argument(
          "--encoder-embed-dim",
          type=int,
          metavar="N",
          help="encoder embedding dimension",
      )
      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",
      )
      parser.add_argument(
          "--encoder-normalize-before",
          action="store_true",
          help="apply layernorm before each encoder block",
      )
      parser.add_argument(
          "--decoder-embed-dim",
          type=int,
          metavar="N",
          help="decoder embedding dimension",
      )
      parser.add_argument(
          "--decoder-ffn-embed-dim",
          type=int,
          metavar="N",
          help="decoder embedding dimension for FFN",
      )
      parser.add_argument(
          "--decoder-layers",
          type=int,
          metavar="N",
          help="num decoder layers",
      )
      parser.add_argument(
          "--decoder-attention-heads",
          type=int,
          metavar="N",
          help="num decoder attention heads",
      )
      parser.add_argument(
          "--decoder-normalize-before",
          action="store_true",
          help="apply layernorm before each decoder block",
      )
      parser.add_argument(
          "--share-decoder-input-output-embed",
          action="store_true",
          help="share decoder input and output embeddings",
      )
      parser.add_argument(
          "--layernorm-embedding",
          action="store_true",
          help="add layernorm to embedding",
      )
      parser.add_argument(
          "--no-scale-embedding",
          action="store_true",
          help="if True, dont scale embeddings",
      )
      parser.add_argument(
          "--load-pretrained-encoder-from",
          type=str,
          metavar="STR",
          help="model to take encoder weights from (for initialization)",
      )
      parser.add_argument(
          "--encoder-freezing-updates",
          type=int,
          metavar="N",
          help="freeze encoder for first N updates",
      )
  
imports: import logging
  import math
  from pathlib import Path
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  from torch import Tensor
  from fairseq import checkpoint_utils, utils
  from fairseq.data.data_utils import lengths_to_padding_mask
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, register_model, register_model_architecture
  from fairseq.models.speech_to_text.hub_interface import S2THubInterface
  from fairseq.models.speech_to_text.modules.convolution import Conv1dSubsampler, Conv2dSubsampler
  from fairseq.models.transformer import Embedding, TransformerDecoder
  from fairseq.modules import FairseqDropout, LayerNorm, PositionalEmbedding, TransformerEncoderLayer
label_desc: Use image node_id 4 for calling the S2TTransformerModel obj's underlying member method code with example usage: obj.add_args(parser) without return types