class_docstr: Convolutional encoder
class_docstr_tok: ["Convolutional","encoder"]
code: def forward(self, src_tokens, src_lengths):
      # embed tokens and positions
      x = self.embed_tokens(src_tokens) + self.embed_positions(
          src_tokens
      )
      x = self.dropout_module(x)
      input_embedding = x.transpose(0, 1)
  
      # project to size of convolution
      x = self.fc1(x)
  
      encoder_padding_mask = src_tokens.eq(
          self.padding_idx
      ).t()  # -> T x B
      if not encoder_padding_mask.any():
          encoder_padding_mask = None
  
      # B x T x C -> T x B x C
      x = x.transpose(0, 1)
  
      # temporal convolutions
      for proj, conv, attention in zip(
          self.projections, self.convolutions, self.attention
      ):
          residual = x if proj is None else proj(x)
  
          if encoder_padding_mask is not None:
              x = x.masked_fill(encoder_padding_mask.unsqueeze(-1), 0)
  
          x = self.dropout_module(x)
          padding_l = (conv.kernel_size[0] - 1) // 2
          padding_r = conv.kernel_size[0] // 2
          x = F.pad(x, (0, 0, 0, 0, padding_l, padding_r))
          x = conv(x)
          x = F.glu(x, dim=2)
          if attention is not None:
              x = attention(x)
          x = (x + residual) * math.sqrt(0.5)
  
      # T x B x C -> B x T x C
      x = x.transpose(1, 0)
  
      # project back to size of embedding
      x = self.fc2(x)
  
      if encoder_padding_mask is not None:
          encoder_padding_mask = encoder_padding_mask.t()  # -> B x T
          x = x.masked_fill(encoder_padding_mask.unsqueeze(-1), 0)
  
      # scale gradients (this only affects backward, not forward)
      x = GradMultiply.apply(x, 1.0 / (2.0 * self.num_attention_layers))
  
      # add output to input embedding for attention
      y = (x + input_embedding.transpose(0, 1)) * math.sqrt(0.5)
  
      return {
          "encoder_out": (x, y),
          "encoder_padding_mask": encoder_padding_mask,  # B x T
      }
  
imports: import logging
  import math
  import os
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import checkpoint_utils
  from fairseq.incremental_decoding_utils import with_incremental_state
  from fairseq.models import CompositeEncoder, FairseqDecoder, FairseqEncoder, FairseqEncoderDecoderModel, register_model, register_model_architecture
  from fairseq.modules import DownsampledMultiHeadAttention, FairseqDropout, GradMultiply, LayerNorm, LearnedPositionalEmbedding, LinearizedConvolution
label_desc: Use image node_id 2 for calling the FConvEncoder obj's underlying member method code with example usage: obj.forward(src_tokens, src_lengths) and returns: dict