class_docstr: Implements one decoder layer in DETR transformer.
  
  Args:
      embed_dims (int): The feature dimension. Same as
          `TransformerEncoderLayer`.
      num_heads (int): Parallel attention heads.
      feedforward_channels (int): Same as `TransformerEncoderLayer`.
      dropout (float): Same as `TransformerEncoderLayer`. Default 0.0.
      order (tuple[str]): The order for decoder layer. Valid examples are
          ('selfattn', 'norm', 'multiheadattn', 'norm', 'ffn', 'norm') and
          ('norm', 'selfattn', 'norm', 'multiheadattn', 'norm', 'ffn').
          Default the former.
      act_cfg (dict): Same as `TransformerEncoderLayer`. Defalut ReLU.
      norm_cfg (dict): Config dict for normalization layer. Default
          layer normalization.
      num_fcs (int): The number of fully-connected layers in FFNs.
class_docstr_tok: ["Implements","one","decoder","layer","in","DETR","transformer",".","Args",":","embed_dims","(","int",")",":","The","feature","dimension",".","Same","as","`","TransformerEncoderLayer","`",".","num_heads","(","int",")",":","Parallel","attention","heads",".","feedforward_channels","(","int",")",":","Same","as","`","TransformerEncoderLayer","`",".","dropout","(","float",")",":","Same","as","`","TransformerEncoderLayer","`",".","Default","0.0.","order","(","tuple","[","str","]",")",":","The","order","for","decoder","layer",".","Valid","examples","are","(","'selfattn","'",",","'norm","'",",","'multiheadattn","'",",","'norm","'",",","'ffn","'",",","'norm","'",")","and","(","'norm","'",",","'selfattn","'",",","'norm","'",",","'multiheadattn","'",",","'norm","'",",","'ffn","'",")",".","Default","the","former",".","act_cfg","(","dict",")",":","Same","as","`","TransformerEncoderLayer","`",".","Defalut","ReLU",".","norm_cfg","(","dict",")",":","Config","dict","for","normalization","layer",".","Default","layer","normalization",".","num_fcs","(","int",")",":","The","number","of","fully-connected","layers","in","FFNs","."]
docstr: Forward function for `TransformerDecoderLayer`.
  
  Args:
      x (Tensor): Input query with shape [num_query, bs, embed_dims].
      memory (Tensor): Tensor got from `TransformerEncoder`, with shape
          [num_key, bs, embed_dims].
      memory_pos (Tensor): The positional encoding for `memory`. Default
          None. Same as `key_pos` in `MultiheadAttention.forward`.
      query_pos (Tensor): The positional encoding for `query`. Default
          None. Same as `query_pos` in `MultiheadAttention.forward`.
      memory_attn_mask (Tensor): ByteTensor mask for `memory`, with
          shape [num_key, num_key]. Same as `attn_mask` in
          `MultiheadAttention.forward`. Default None.
      target_attn_mask (Tensor): ByteTensor mask for `x`, with shape
          [num_query, num_query]. Same as `attn_mask` in
          `MultiheadAttention.forward`. Default None.
      memory_key_padding_mask (Tensor): ByteTensor for `memory`, with
          shape [bs, num_key]. Same as `key_padding_mask` in
          `MultiheadAttention.forward`. Default None.
      target_key_padding_mask (Tensor): ByteTensor for `x`, with shape
          [bs, num_query]. Same as `key_padding_mask` in
          `MultiheadAttention.forward`. Default None.
  
  Returns:
      Tensor: forwarded results with shape [num_query, bs, embed_dims].
docstr_tok: ["Forward","function","for","`","TransformerDecoderLayer","`",".","Args",":","x","(","Tensor",")",":","Input","query","with","shape","[","num_query",",","bs",",","embed_dims","]",".","memory","(","Tensor",")",":","Tensor","got","from","`","TransformerEncoder","`",",","with","shape","[","num_key",",","bs",",","embed_dims","]",".","memory_pos","(","Tensor",")",":","The","positional","encoding","for","`","memory","`",".","Default","None",".","Same","as","`","key_pos","`","in","`","MultiheadAttention.forward","`",".","query_pos","(","Tensor",")",":","The","positional","encoding","for","`","query","`",".","Default","None",".","Same","as","`","query_pos","`","in","`","MultiheadAttention.forward","`",".","memory_attn_mask","(","Tensor",")",":","ByteTensor","mask","for","`","memory","`",",","with","shape","[","num_key",",","num_key","]",".","Same","as","`","attn_mask","`","in","`","MultiheadAttention.forward","`",".","Default","None",".","target_attn_mask","(","Tensor",")",":","ByteTensor","mask","for","`","x","`",",","with","shape","[","num_query",",","num_query","]",".","Same","as","`","attn_mask","`","in","`","MultiheadAttention.forward","`",".","Default","None",".","memory_key_padding_mask","(","Tensor",")",":","ByteTensor","for","`","memory","`",",","with","shape","[","bs",",","num_key","]",".","Same","as","`","key_padding_mask","`","in","`","MultiheadAttention.forward","`",".","Default","None",".","target_key_padding_mask","(","Tensor",")",":","ByteTensor","for","`","x","`",",","with","shape","[","bs",",","num_query","]",".","Same","as","`","key_padding_mask","`","in","`","MultiheadAttention.forward","`",".","Default","None",".","Returns",":","Tensor",":","forwarded","results","with","shape","[","num_query",",","bs",",","embed_dims","]","."]
code: def forward(
      self,
      x,
      memory,
      memory_pos=None,
      query_pos=None,
      memory_attn_mask=None,
      target_attn_mask=None,
      memory_key_padding_mask=None,
      target_key_padding_mask=None,
  ):
      """Forward function for `TransformerDecoderLayer`.
  
      Args:
          x (Tensor): Input query with shape [num_query, bs, embed_dims].
          memory (Tensor): Tensor got from `TransformerEncoder`, with shape
              [num_key, bs, embed_dims].
          memory_pos (Tensor): The positional encoding for `memory`. Default
              None. Same as `key_pos` in `MultiheadAttention.forward`.
          query_pos (Tensor): The positional encoding for `query`. Default
              None. Same as `query_pos` in `MultiheadAttention.forward`.
          memory_attn_mask (Tensor): ByteTensor mask for `memory`, with
              shape [num_key, num_key]. Same as `attn_mask` in
              `MultiheadAttention.forward`. Default None.
          target_attn_mask (Tensor): ByteTensor mask for `x`, with shape
              [num_query, num_query]. Same as `attn_mask` in
              `MultiheadAttention.forward`. Default None.
          memory_key_padding_mask (Tensor): ByteTensor for `memory`, with
              shape [bs, num_key]. Same as `key_padding_mask` in
              `MultiheadAttention.forward`. Default None.
          target_key_padding_mask (Tensor): ByteTensor for `x`, with shape
              [bs, num_query]. Same as `key_padding_mask` in
              `MultiheadAttention.forward`. Default None.
  
      Returns:
          Tensor: forwarded results with shape [num_query, bs, embed_dims].
      """
      norm_cnt = 0
      inp_residual = x
      for layer in self.order:
          if layer == "selfattn":
              query = key = value = x
              x = self.self_attn(
                  query,
                  key,
                  value,
                  inp_residual if self.pre_norm else None,
                  query_pos,
                  key_pos=query_pos,
                  attn_mask=target_attn_mask,
                  key_padding_mask=target_key_padding_mask,
              )
              inp_residual = x
          elif layer == "norm":
              x = self.norms[norm_cnt](x)
              norm_cnt += 1
          elif layer == "multiheadattn":
              query = x
              key = value = memory
              x = self.multihead_attn(
                  query,
                  key,
                  value,
                  inp_residual if self.pre_norm else None,
                  query_pos,
                  key_pos=memory_pos,
                  attn_mask=memory_attn_mask,
                  key_padding_mask=memory_key_padding_mask,
              )
              inp_residual = x
          elif layer == "ffn":
              x = self.ffn(x, inp_residual if self.pre_norm else None)
      return x
  
imports: import torch
  import torch.nn
  from mmcv.cnn import Linear, build_activation_layer, build_norm_layer, xavier_init
  from .builder import TRANSFORMER
label_desc: Use image node_id 2 for calling the TransformerDecoderLayer obj's underlying member method code with example usage: obj.forward(x, memory, memory_pos, query_pos, memory_attn_mask, target_attn_mask, memory_key_padding_mask, target_key_padding_mask) and returns: x