class_docstr: Decoder based on "Convolutional Sequence to Sequence Learning"
  :cite:`DBLP:journals/corr/GehringAGYD17`.
  
  Consists of residual convolutional layers, with ConvMultiStepAttention.
class_docstr_tok: ["Decoder","based","on","``","Convolutional","Sequence","to","Sequence","Learning","''",":","cite",":","`","DBLP",":","journals\/corr\/GehringAGYD17","`",".","Consists","of","residual","convolutional","layers",",","with","ConvMultiStepAttention","."]
code: def __init__(
      self,
      num_layers,
      hidden_size,
      attn_type,
      copy_attn,
      cnn_kernel_width,
      dropout,
      embeddings,
      copy_attn_type,
  ):
      super(CNNDecoder, self).__init__()
  
      self.cnn_kernel_width = cnn_kernel_width
      self.embeddings = embeddings
  
      # Decoder State
      self.state = {}
  
      input_size = self.embeddings.embedding_size
      self.linear = nn.Linear(input_size, hidden_size)
      self.conv_layers = nn.ModuleList(
          [
              GatedConv(hidden_size, cnn_kernel_width, dropout, True)
              for i in range(num_layers)
          ]
      )
      self.attn_layers = nn.ModuleList(
          [
              ConvMultiStepAttention(hidden_size)
              for i in range(num_layers)
          ]
      )
  
      # CNNDecoder has its own attention mechanism.
      # Set up a separate copy attention layer if needed.
      assert not copy_attn, "Copy mechanism not yet tested in conv2conv"
      if copy_attn:
          self.copy_attn = GlobalAttention(
              hidden_size, attn_type=copy_attn_type
          )
      else:
          self.copy_attn = None
  
file_path: OpenNMT-py/onmt/decoders/cnn_decoder.py
imports: import torch
  import torch.nn
  from onmt.modules import ConvMultiStepAttention, GlobalAttention
  from onmt.utils.cnn_factory import shape_transform, GatedConv
  from onmt.decoders.decoder import DecoderBase
label_desc: Use image node_id 1 to create a new CNNDecoder object from inherited base classes: DecoderBase with example: obj = CNNDecoder(num_layers, hidden_size, attn_type, copy_attn, cnn_kernel_width, dropout, embeddings, copy_attn_type)