class_docstr: Convolutional encoder consisting of `len(convolutions)` layers.
  
  Args:
      dictionary (~fairseq.data.Dictionary): encoding dictionary
      embed_dim (int, optional): embedding dimension
      embed_dict (str, optional): filename from which to load pre-trained
          embeddings
      max_positions (int, optional): maximum supported input sequence length
      convolutions (list, optional): the convolutional layer structure. Each
          list item `i` corresponds to convolutional layer `i`. Layers are
          given as ``(out_channels, kernel_width, [residual])``. Residual
          connections are added between layers when ``residual=1`` (which is
          the default behavior).
      dropout (float, optional): dropout to be applied before each conv layer
class_docstr_tok: ["Convolutional","encoder","consisting","of","`","len","(","convolutions",")","`","layers",".","Args",":","dictionary","(","~fairseq.data.Dictionary",")",":","encoding","dictionary","embed_dim","(","int",",","optional",")",":","embedding","dimension","embed_dict","(","str",",","optional",")",":","filename","from","which","to","load","pre-trained","embeddings","max_positions","(","int",",","optional",")",":","maximum","supported","input","sequence","length","convolutions","(","list",",","optional",")",":","the","convolutional","layer","structure",".","Each","list","item","`","i","`","corresponds","to","convolutional","layer","`","i","`",".","Layers","are","given","as","``","(","out_channels",",","kernel_width",",","[","residual","]",")","``",".","Residual","connections","are","added","between","layers","when","``","residual=1","``","(","which","is","the","default","behavior",")",".","dropout","(","float",",","optional",")",":","dropout","to","be","applied","before","each","conv","layer"]
docstr: Args:
      src_tokens (LongTensor): tokens in the source language of shape
          `(batch, src_len)`
      src_lengths (LongTensor): lengths of each source sentence of shape
          `(batch)`
  
  Returns:
      dict:
          - **encoder_out** (tuple): a tuple with two elements, where the
            first element is the last encoder layer's output and the
            second element is the same quantity summed with the input
            embedding (used for attention). The shape of both tensors is
            `(batch, src_len, embed_dim)`.
          - **encoder_padding_mask** (ByteTensor): the positions of
            padding elements of shape `(batch, src_len)`
docstr_tok: ["Args",":","src_tokens","(","LongTensor",")",":","tokens","in","the","source","language","of","shape","`","(","batch",",","src_len",")","`","src_lengths","(","LongTensor",")",":","lengths","of","each","source","sentence","of","shape","`","(","batch",")","`","Returns",":","dict",":","-","*","*","encoder_out","*","*","(","tuple",")",":","a","tuple","with","two","elements",",","where","the","first","element","is","the","last","encoder","layer","'s","output","and","the","second","element","is","the","same","quantity","summed","with","the","input","embedding","(","used","for","attention",")",".","The","shape","of","both","tensors","is","`","(","batch",",","src_len",",","embed_dim",")","`",".","-","*","*","encoder_padding_mask","*","*","(","ByteTensor",")",":","the","positions","of","padding","elements","of","shape","`","(","batch",",","src_len",")","`"]
code: def forward(self, src_tokens, src_lengths):
      """
      Args:
          src_tokens (LongTensor): tokens in the source language of shape
              `(batch, src_len)`
          src_lengths (LongTensor): lengths of each source sentence of shape
              `(batch)`
  
      Returns:
          dict:
              - **encoder_out** (tuple): a tuple with two elements, where the
                first element is the last encoder layer's output and the
                second element is the same quantity summed with the input
                embedding (used for attention). The shape of both tensors is
                `(batch, src_len, embed_dim)`.
              - **encoder_padding_mask** (ByteTensor): the positions of
                padding elements of shape `(batch, src_len)`
      """
      # embed tokens and positions
      x = self.embed_tokens(src_tokens) + self.embed_positions(
          src_tokens
      )
      x = self.dropout_module(x)
      input_embedding = x
  
      # project to size of convolution
      x = self.fc1(x)
  
      # used to mask padding in input
      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)
  
      residuals = [x]
      # temporal convolutions
      for proj, conv, res_layer in zip(
          self.projections, self.convolutions, self.residuals
      ):
          if res_layer > 0:
              residual = residuals[-res_layer]
              residual = residual if proj is None else proj(residual)
          else:
              residual = None
  
          if encoder_padding_mask is not None:
              x = x.masked_fill(encoder_padding_mask.unsqueeze(-1), 0)
  
          x = self.dropout_module(x)
          if conv.kernel_size[0] % 2 == 1:
              # padding is implicit in the conv
              x = conv(x)
          else:
              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 residual is not None:
              x = (x + residual) * math.sqrt(0.5)
          residuals.append(x)
  
      # 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) * math.sqrt(0.5)
  
      return {
          "encoder_out": (x, y),
          "encoder_padding_mask": encoder_padding_mask,  # B x T
      }
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.modules import AdaptiveSoftmax, BeamableMM, FairseqDropout, GradMultiply, 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