class_docstr: Implements the decoder in DETR transformer.
  
  Args:
      num_layers (int): The number of `TransformerDecoderLayer`.
      embed_dims (int): Same as `TransformerDecoderLayer`.
      num_heads (int): Same as `TransformerDecoderLayer`.
      feedforward_channels (int): Same as `TransformerDecoderLayer`.
      dropout (float): Same as `TransformerDecoderLayer`. Default 0.0.
      order (tuple[str]): Same as `TransformerDecoderLayer`.
      act_cfg (dict): Same as `TransformerDecoderLayer`. Defalut ReLU.
      norm_cfg (dict): Same as `TransformerDecoderLayer`. Default
          layer normalization.
      num_fcs (int): Same as `TransformerDecoderLayer`. Default 2.
class_docstr_tok: ["Implements","the","decoder","in","DETR","transformer",".","Args",":","num_layers","(","int",")",":","The","number","of","`","TransformerDecoderLayer","`",".","embed_dims","(","int",")",":","Same","as","`","TransformerDecoderLayer","`",".","num_heads","(","int",")",":","Same","as","`","TransformerDecoderLayer","`",".","feedforward_channels","(","int",")",":","Same","as","`","TransformerDecoderLayer","`",".","dropout","(","float",")",":","Same","as","`","TransformerDecoderLayer","`",".","Default","0.0.","order","(","tuple","[","str","]",")",":","Same","as","`","TransformerDecoderLayer","`",".","act_cfg","(","dict",")",":","Same","as","`","TransformerDecoderLayer","`",".","Defalut","ReLU",".","norm_cfg","(","dict",")",":","Same","as","`","TransformerDecoderLayer","`",".","Default","layer","normalization",".","num_fcs","(","int",")",":","Same","as","`","TransformerDecoderLayer","`",".","Default","2","."]
docstr: Forward function for `TransformerDecoder`.
  
  Args:
      x (Tensor): Input query. Same in `TransformerDecoderLayer.forward`.
      memory (Tensor): Same in `TransformerDecoderLayer.forward`.
      memory_pos (Tensor): Same in `TransformerDecoderLayer.forward`.
          Default None.
      query_pos (Tensor): Same in `TransformerDecoderLayer.forward`.
          Default None.
      memory_attn_mask (Tensor): Same in
          `TransformerDecoderLayer.forward`. Default None.
      target_attn_mask (Tensor): Same in
          `TransformerDecoderLayer.forward`. Default None.
      memory_key_padding_mask (Tensor): Same in
          `TransformerDecoderLayer.forward`. Default None.
      target_key_padding_mask (Tensor): Same in
          `TransformerDecoderLayer.forward`. Default None.
  
  Returns:
      Tensor: Results with shape [num_query, bs, embed_dims].
docstr_tok: ["Forward","function","for","`","TransformerDecoder","`",".","Args",":","x","(","Tensor",")",":","Input","query",".","Same","in","`","TransformerDecoderLayer.forward","`",".","memory","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","memory_pos","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","Default","None",".","query_pos","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","Default","None",".","memory_attn_mask","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","Default","None",".","target_attn_mask","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","Default","None",".","memory_key_padding_mask","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","Default","None",".","target_key_padding_mask","(","Tensor",")",":","Same","in","`","TransformerDecoderLayer.forward","`",".","Default","None",".","Returns",":","Tensor",":","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 `TransformerDecoder`.
  
      Args:
          x (Tensor): Input query. Same in `TransformerDecoderLayer.forward`.
          memory (Tensor): Same in `TransformerDecoderLayer.forward`.
          memory_pos (Tensor): Same in `TransformerDecoderLayer.forward`.
              Default None.
          query_pos (Tensor): Same in `TransformerDecoderLayer.forward`.
              Default None.
          memory_attn_mask (Tensor): Same in
              `TransformerDecoderLayer.forward`. Default None.
          target_attn_mask (Tensor): Same in
              `TransformerDecoderLayer.forward`. Default None.
          memory_key_padding_mask (Tensor): Same in
              `TransformerDecoderLayer.forward`. Default None.
          target_key_padding_mask (Tensor): Same in
              `TransformerDecoderLayer.forward`. Default None.
  
      Returns:
          Tensor: Results with shape [num_query, bs, embed_dims].
      """
      intermediate = []
      for layer in self.layers:
          x = layer(
              x,
              memory,
              memory_pos,
              query_pos,
              memory_attn_mask,
              target_attn_mask,
              memory_key_padding_mask,
              target_key_padding_mask,
          )
          if self.return_intermediate:
              intermediate.append(self.norm(x))
      if self.norm is not None:
          x = self.norm(x)
          if self.return_intermediate:
              intermediate.pop()
              intermediate.append(x)
      if self.return_intermediate:
          return torch.stack(intermediate)
      return x.unsqueeze(0)
  
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 TransformerDecoder 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, torch