class_docstr: Speech-to-text Transformer encoder that consists of input subsampler and
  Transformer encoder.
class_docstr_tok: ["Speech-to-text","Transformer","encoder","that","consists","of","input","subsampler","and","Transformer","encoder","."]
code: def _forward(self, src_tokens, src_lengths, return_all_hiddens=False):
      x, input_lengths = self.subsample(src_tokens, src_lengths)
      x = self.embed_scale * x
  
      encoder_padding_mask = lengths_to_padding_mask(input_lengths)
      positions = self.embed_positions(encoder_padding_mask).transpose(
          0, 1
      )
      x += positions
      x = self.dropout_module(x)
  
      encoder_states = []
  
      for layer in self.transformer_layers:
          x = layer(x, encoder_padding_mask)
          if return_all_hiddens:
              encoder_states.append(x)
  
      if self.layer_norm is not None:
          x = self.layer_norm(x)
  
      return {
          "encoder_out": [x],  # T x B x C
          "encoder_padding_mask": [encoder_padding_mask]
          if encoder_padding_mask.any()
          else [],  # B x T
          "encoder_embedding": [],  # B x T x C
          "encoder_states": encoder_states,  # List[T x B x C]
          "src_tokens": [],
          "src_lengths": [],
      }
  
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 2 for calling the S2TTransformerEncoder obj's underlying member method code with example usage: obj._forward(src_tokens, src_lengths, return_all_hiddens) and returns: dict