class_docstr: LightConv decoder consisting of *args.decoder_layers* layers. Each layer
  is a :class:`LightConvDecoderLayer`.
  
  Args:
      args (argparse.Namespace): parsed command-line arguments
      dictionary (~fairseq.data.Dictionary): decoding dictionary
      embed_tokens (torch.nn.Embedding): output embedding
      no_encoder_attn (bool, optional): whether to attend to encoder outputs.
          Default: ``False``
class_docstr_tok: ["LightConv","decoder","consisting","of","*","args.decoder_layers","*","layers",".","Each","layer","is","a",":","class",":","`","LightConvDecoderLayer","`",".","Args",":","args","(","argparse.Namespace",")",":","parsed","command-line","arguments","dictionary","(","~fairseq.data.Dictionary",")",":","decoding","dictionary","embed_tokens","(","torch.nn.Embedding",")",":","output","embedding","no_encoder_attn","(","bool",",","optional",")",":","whether","to","attend","to","encoder","outputs",".","Default",":","``","False","``"]
docstr: Args:
      prev_output_tokens (LongTensor): previous decoder outputs of shape
          `(batch, tgt_len)`, for teacher forcing
      encoder_out (Tensor, optional): output from the encoder, used for
          encoder-side attention
      incremental_state (dict): dictionary used for storing state during
          :ref:`Incremental decoding`
  
  Returns:
      tuple:
          - the last decoder layer's output of shape `(batch, tgt_len,
            vocab)`
          - the last decoder layer's attention weights of shape `(batch,
            tgt_len, src_len)`
docstr_tok: ["Args",":","prev_output_tokens","(","LongTensor",")",":","previous","decoder","outputs","of","shape","`","(","batch",",","tgt_len",")","`",",","for","teacher","forcing","encoder_out","(","Tensor",",","optional",")",":","output","from","the","encoder",",","used","for","encoder-side","attention","incremental_state","(","dict",")",":","dictionary","used","for","storing","state","during",":","ref",":","`","Incremental","decoding","`","Returns",":","tuple",":","-","the","last","decoder","layer","'s","output","of","shape","`","(","batch",",","tgt_len",",","vocab",")","`","-","the","last","decoder","layer","'s","attention","weights","of","shape","`","(","batch",",","tgt_len",",","src_len",")","`"]
code: def forward(
      self,
      prev_output_tokens: Tensor,
      encoder_out: Optional[Dict[str, List[Tensor]]] = None,
      incremental_state: Optional[
          Dict[str, Dict[str, Optional[Tensor]]]
      ] = None,
      src_lengths: Optional[Any] = None,
  ):
      """
      Args:
          prev_output_tokens (LongTensor): previous decoder outputs of shape
              `(batch, tgt_len)`, for teacher forcing
          encoder_out (Tensor, optional): output from the encoder, used for
              encoder-side attention
          incremental_state (dict): dictionary used for storing state during
              :ref:`Incremental decoding`
  
      Returns:
          tuple:
              - the last decoder layer's output of shape `(batch, tgt_len,
                vocab)`
              - the last decoder layer's attention weights of shape `(batch,
                tgt_len, src_len)`
      """
      # embed positions
      positions = (
          self.embed_positions(
              prev_output_tokens,
              incremental_state=incremental_state,
          )
          if self.embed_positions is not None
          else None
      )
  
      if incremental_state is not None:
          prev_output_tokens = prev_output_tokens[:, -1:]
          if positions is not None:
              positions = positions[:, -1:]
  
      # embed tokens and positions
      x = self.embed_scale * self.embed_tokens(
          prev_output_tokens.contiguous()
      )
  
      if self.project_in_dim is not None:
          x = self.project_in_dim(x)
  
      if positions is not None:
          x += positions
      x = self.dropout_module(x)
  
      # B x T x C -> T x B x C
      x = x.transpose(0, 1)
      attn = None
  
      inner_states: List[Optional[Tensor]] = [x]
  
      # decoder layers
      attn: Optional[Tensor] = None
      for layer in self.layers:
          encoder: Optional[Tensor] = None
          encoder_padding_mask: Optional[Tensor] = None
          if encoder_out is not None:
              if len(encoder_out["encoder_out"]) > 0:
                  encoder = encoder_out["encoder_out"][0]
              if (
                  "encoder_padding_mask" in encoder_out
                  and len(encoder_out["encoder_padding_mask"]) > 0
              ):
                  encoder_padding_mask = encoder_out[
                      "encoder_padding_mask"
                  ][0]
          x, attn = layer(
              x,
              encoder,
              encoder_padding_mask,
              incremental_state,
          )
          inner_states.append(x)
  
      if self.layer_norm is not None:
          x = self.layer_norm(x)
  
      # T x B x C -> B x T x C
      x = x.transpose(0, 1)
  
      if self.project_out_dim is not None:
          x = self.project_out_dim(x)
  
      if self.adaptive_softmax is None:
          # project back to size of vocabulary
          x = self.output_projection(x)
  
      return x, {"attn": [attn], "inner_states": inner_states}
  
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 LightConvDecoder obj's underlying member method code with example usage: obj.forward(prev_output_tokens, encoder_out, incremental_state, src_lengths) and returns: x,  dict