class_docstr: Conformer Encoder for speech translation based on https://arxiv.org/abs/2005.08100
code: def __init__(self, args):
      super().__init__(None)
  
      self.encoder_freezing_updates = args.encoder_freezing_updates
      self.num_updates = 0
  
      self.embed_scale = math.sqrt(args.encoder_embed_dim)
      if args.no_scale_embedding:
          self.embed_scale = 1.0
      self.padding_idx = 1
      self.conv_version = args.conv_version
      if self.conv_version == "s2t_transformer":
          self.subsample = Conv1dSubsampler(
              args.input_feat_per_channel * args.input_channels,
              args.conv_channels,
              args.encoder_embed_dim,
              [int(k) for k in args.conv_kernel_sizes.split(",")],
          )
      elif self.conv_version == "convtransformer":
          self.subsample = Conv2dSubsampler(
              args.input_channels,
              args.input_feat_per_channel,
              args.conv_out_channels,
              args.encoder_embed_dim,
          )
      self.pos_enc_type = args.pos_enc_type
      if self.pos_enc_type == "rel_pos":
          self.embed_positions = RelPositionalEncoding(
              args.max_source_positions, args.encoder_embed_dim
          )
      elif self.pos_enc_type == "rope":
          self.embed_positions = None
      else:  # Use absolute positional embedding
          self.pos_enc_type = "abs"
          self.embed_positions = PositionalEmbedding(
              args.max_source_positions,
              args.encoder_embed_dim,
              self.padding_idx,
          )
  
      self.linear = torch.nn.Linear(
          args.encoder_embed_dim, args.encoder_embed_dim
      )
      self.dropout = torch.nn.Dropout(args.dropout)
      self.conformer_layers = torch.nn.ModuleList(
          [
              ConformerEncoderLayer(
                  embed_dim=args.encoder_embed_dim,
                  ffn_embed_dim=args.encoder_ffn_embed_dim,
                  attention_heads=args.encoder_attention_heads,
                  dropout=args.dropout,
                  depthwise_conv_kernel_size=args.depthwise_conv_kernel_size,
                  attn_type=args.attn_type,
                  pos_enc_type=self.pos_enc_type,
                  use_fp16=args.fp16,
              )
              for _ in range(args.encoder_layers)
          ]
      )
  
imports: import logging
  import math
  from pathlib import Path
  import torch
  from fairseq import checkpoint_utils
  from fairseq.data.data_utils import lengths_to_padding_mask
  from fairseq.models import FairseqEncoder, register_model, register_model_architecture
  from fairseq.models.speech_to_text.modules.convolution import Conv1dSubsampler, Conv2dSubsampler
  from fairseq.models.speech_to_text.s2t_transformer import S2TTransformerEncoder, S2TTransformerModel
  from fairseq.models.speech_to_text.s2t_transformer import base_architecture
  from fairseq.modules import PositionalEmbedding, RelPositionalEncoding
  from fairseq.modules.conformer_layer import ConformerEncoderLayer
label_desc: Use image node_id 1 to create a new S2TConformerEncoder object from inherited base classes: FairseqEncoder with example: obj = S2TConformerEncoder(args)