class_docstr: Implementation of `DETR: End-to-End Object Detection with Transformers.
  
  <https://arxiv.org/pdf/2005.12872>`_.
  
  Code is modified from the `official github repo
  <https://github.com/facebookresearch/detr>`_.
docstr: Forward with Transformer decoder.
  
  The forward procedure of the transformer is defined as:
  'pre_transformer' -> 'encoder' -> 'pre_decoder' -> 'decoder'
  More details can be found at `TransformerDetector.forward_transformer`
  in `mmdet/detector/base_detr.py`.
  
  Args:
      query (Tensor): The queries of decoder inputs, has shape
          (bs, num_queries, dim).
      query_pos (Tensor): The positional queries of decoder inputs,
          has shape (bs, num_queries, dim).
      memory (Tensor): The output embeddings of the Transformer encoder,
          has shape (bs, num_feat_points, dim).
      memory_mask (Tensor): ByteTensor, the padding mask of the memory,
          has shape (bs, num_feat_points).
      memory_pos (Tensor): The positional embeddings of memory, has
          shape (bs, num_feat_points, dim).
  
  Returns:
      dict: The dictionary of decoder outputs, which includes the
      `hidden_states` of the decoder output.
  
      - hidden_states (Tensor): Has shape
        (num_decoder_layers, bs, num_queries, dim)
docstr_tok: ["Forward","with","Transformer","decoder",".","The","forward","procedure","of","the","transformer","is","defined","as",":","'pre_transformer","'","-",">","'encoder","'","-",">","'pre_decoder","'","-",">","'decoder'","More","details","can","be","found","at","`","TransformerDetector.forward_transformer","`","in","`","mmdet\/detector\/base_detr.py","`",".","Args",":","query","(","Tensor",")",":","The","queries","of","decoder","inputs",",","has","shape","(","bs",",","num_queries",",","dim",")",".","query_pos","(","Tensor",")",":","The","positional","queries","of","decoder","inputs",",","has","shape","(","bs",",","num_queries",",","dim",")",".","memory","(","Tensor",")",":","The","output","embeddings","of","the","Transformer","encoder",",","has","shape","(","bs",",","num_feat_points",",","dim",")",".","memory_mask","(","Tensor",")",":","ByteTensor",",","the","padding","mask","of","the","memory",",","has","shape","(","bs",",","num_feat_points",")",".","memory_pos","(","Tensor",")",":","The","positional","embeddings","of","memory",",","has","shape","(","bs",",","num_feat_points",",","dim",")",".","Returns",":","dict",":","The","dictionary","of","decoder","outputs",",","which","includes","the","`","hidden_states","`","of","the","decoder","output",".","-","hidden_states","(","Tensor",")",":","Has","shape","(","num_decoder_layers",",","bs",",","num_queries",",","dim",")"]
code: def forward_decoder(
      self,
      query: Tensor,
      query_pos: Tensor,
      memory: Tensor,
      memory_mask: Tensor,
      memory_pos: Tensor,
  ) -> Dict:
      """Forward with Transformer decoder.
  
      The forward procedure of the transformer is defined as:
      'pre_transformer' -> 'encoder' -> 'pre_decoder' -> 'decoder'
      More details can be found at `TransformerDetector.forward_transformer`
      in `mmdet/detector/base_detr.py`.
  
      Args:
          query (Tensor): The queries of decoder inputs, has shape
              (bs, num_queries, dim).
          query_pos (Tensor): The positional queries of decoder inputs,
              has shape (bs, num_queries, dim).
          memory (Tensor): The output embeddings of the Transformer encoder,
              has shape (bs, num_feat_points, dim).
          memory_mask (Tensor): ByteTensor, the padding mask of the memory,
              has shape (bs, num_feat_points).
          memory_pos (Tensor): The positional embeddings of memory, has
              shape (bs, num_feat_points, dim).
  
      Returns:
          dict: The dictionary of decoder outputs, which includes the
          `hidden_states` of the decoder output.
  
          - hidden_states (Tensor): Has shape
            (num_decoder_layers, bs, num_queries, dim)
      """
  
      hidden_states = self.decoder(
          query=query,
          key=memory,
          value=memory,
          query_pos=query_pos,
          key_pos=memory_pos,
          key_padding_mask=memory_mask,
      )  # for cross_attn
  
      head_inputs_dict = dict(hidden_states=hidden_states)
      return head_inputs_dict
  
file_path: mmdetection/mmdet/models/detectors/detr.py
imports: from typing import Dict, Tuple
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from mmdet.registry import MODELS
  from mmdet.structures import OptSampleList
  from ..layers import DetrTransformerDecoder, DetrTransformerEncoder, SinePositionalEncoding
  from .base_detr import DetectionTransformer
label_desc: Use image node_id 6 for calling the DETR obj's underlying member method code with example usage: obj.forward_decoder(query, query_pos, memory, memory_mask, memory_pos) and returns: head_inputs_dict