class_docstr: LightConv encoder consisting of *args.encoder_layers* layers. Each layer
  is a :class:`LightConvEncoderLayer`.
  
  Args:
      args (argparse.Namespace): parsed command-line arguments
      dictionary (~fairseq.data.Dictionary): encoding dictionary
      embed_tokens (torch.nn.Embedding): input embedding
class_docstr_tok: ["LightConv","encoder","consisting","of","*","args.encoder_layers","*","layers",".","Each","layer","is","a",":","class",":","`","LightConvEncoderLayer","`",".","Args",":","args","(","argparse.Namespace",")",":","parsed","command-line","arguments","dictionary","(","~fairseq.data.Dictionary",")",":","encoding","dictionary","embed_tokens","(","torch.nn.Embedding",")",":","input","embedding"]
docstr: Args:
      src_tokens (LongTensor): tokens in the source language of shape
          `(batch, src_len)`
  
  Returns:
      dict:
          - **encoder_out** (Tensor): the last encoder layer's output of
            shape `(src_len, batch, 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",")","`","Returns",":","dict",":","-","*","*","encoder_out","*","*","(","Tensor",")",":","the","last","encoder","layer","'s","output","of","shape","`","(","src_len",",","batch",",","embed_dim",")","`","-","*","*","encoder_padding_mask","*","*","(","ByteTensor",")",":","the","positions","of","padding","elements","of","shape","`","(","batch",",","src_len",")","`"]
code: def forward(
      self, src_tokens: Tensor, src_lengths: Optional[Tensor] = None
  ) -> Dict[str, List[Tensor]]:
      """
      Args:
          src_tokens (LongTensor): tokens in the source language of shape
              `(batch, src_len)`
  
      Returns:
          dict:
              - **encoder_out** (Tensor): the last encoder layer's output of
                shape `(src_len, batch, embed_dim)`
              - **encoder_padding_mask** (ByteTensor): the positions of
                padding elements of shape `(batch, src_len)`
      """
      # embed tokens and positions
      x = self.embed_scale * self.embed_tokens(src_tokens)
      if self.embed_positions is not None:
          x += self.embed_positions(src_tokens)
      x = self.dropout_module(x)
  
      # B x T x C -> T x B x C
      x = x.transpose(0, 1)
  
      # compute padding mask
      encoder_padding_mask = src_tokens.eq(self.padding_idx)  # B x T
      if not encoder_padding_mask.any():
          encoder_mask = None
      else:
          encoder_mask = encoder_padding_mask
  
      # encoder layers
      for layer in self.layers:
          x = layer(x, encoder_mask)
  
      if self.layer_norm is not None:
          x = self.layer_norm(x)
  
      output_dict: Dict[str, List[Tensor]] = {}
      if src_lengths is not None:
          output_dict["src_lengths"] = [src_lengths]
      output_dict["encoder_out"] = [x]  # T x B x C
      if encoder_mask is not None:
          output_dict["encoder_padding_mask"] = [encoder_mask]  # B x T
  
      return output_dict
  
imports: import math
  from typing import Any, Dict, List, Optional, Tuple
  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, DynamicConv_scripatable, FairseqDropout, LayerNorm, LightweightConv, MultiheadAttention, PositionalEmbedding
  from fairseq.utils import safe_hasattr
  from torch import Tensor
label_desc: Use image node_id 2 for calling the LightConvEncoder obj's underlying member method code with example usage: obj.forward(src_tokens, src_lengths) and returns: output_dict