class_docstr: TransformerDecoderLayer class.
  Args:
      d_model (int): dimension of model
      nhead (int): number of head
      dim_feedforward (int): dimension of feedforward
      dropout (float): dropout
      activation (str): activation
class_docstr_tok: ["TransformerDecoderLayer","class",".","Args",":","d_model","(","int",")",":","dimension","of","model","nhead","(","int",")",":","number","of","head","dim_feedforward","(","int",")",":","dimension","of","feedforward","dropout","(","float",")",":","dropout","activation","(","str",")",":","activation"]
code: def forward(
      self,
      tgt,
      memory,
      tgt_mask: Optional[Tensor] = None,
      memory_mask: Optional[Tensor] = None,
      tgt_key_padding_mask: Optional[Tensor] = None,
      memory_key_padding_mask: Optional[Tensor] = None,
      pos: Optional[Tensor] = None,
      query_pos: Optional[Tensor] = None,
  ):
      tgt2 = self.norm1(tgt)
      q = k = self.with_pos_embed(tgt2, query_pos)
      tgt2 = self.self_attn(
          q,
          k,
          value=tgt2,
          attn_mask=tgt_mask,
          key_padding_mask=tgt_key_padding_mask,
      )[0]
      tgt = tgt + self.dropout1(tgt2)
      tgt2 = self.norm2(tgt)
      tgt2 = self.multihead_attn(
          query=self.with_pos_embed(tgt2, query_pos),
          key=self.with_pos_embed(memory, pos),
          value=memory,
          attn_mask=memory_mask,
          key_padding_mask=memory_key_padding_mask,
      )[0]
      tgt = tgt + self.dropout2(tgt2)
      tgt2 = self.norm3(tgt)
      tgt2 = self.linear2(
          self.dropout(self.activation(self.linear1(tgt2)))
      )
      tgt = tgt + self.dropout3(tgt2)
      return tgt
  
imports: import copy
  import torch
  import torch.nn.functional
  from typing import Optional
  from torch import nn, Tensor
label_desc: Use image node_id 3 for calling the TransformerDecoderLayer obj's underlying member method code with example usage: obj.forward(tgt, memory, tgt_mask, memory_mask, tgt_key_padding_mask, memory_key_padding_mask, pos, query_pos) and returns: tgt