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: Prepare intermediate variables before entering Transformer decoder,
  such as `query`, `query_pos`.
  
  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:
      memory (Tensor): The output embeddings of the Transformer encoder,
          has shape (bs, num_feat_points, dim).
  
  Returns:
      tuple[dict, dict]: The first dict contains the inputs of decoder
      and the second dict contains the inputs of the bbox_head function.
  
      - decoder_inputs_dict (dict): The keyword args dictionary of
        `self.forward_decoder()`, which includes 'query', 'query_pos',
        'memory'.
      - head_inputs_dict (dict): The keyword args dictionary of the
        bbox_head functions, which is usually empty, or includes
        `enc_outputs_class` and `enc_outputs_class` when the detector
        support 'two stage' or 'query selection' strategies.
docstr_tok: ["Prepare","intermediate","variables","before","entering","Transformer","decoder",",","such","as","`","query","`",",","`","query_pos","`",".","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",":","memory","(","Tensor",")",":","The","output","embeddings","of","the","Transformer","encoder",",","has","shape","(","bs",",","num_feat_points",",","dim",")",".","Returns",":","tuple","[","dict",",","dict","]",":","The","first","dict","contains","the","inputs","of","decoder","and","the","second","dict","contains","the","inputs","of","the","bbox_head","function",".","-","decoder_inputs_dict","(","dict",")",":","The","keyword","args","dictionary","of","`","self.forward_decoder","(",")","`",",","which","includes","'query","'",",","'query_pos","'",",","'memory","'",".","-","head_inputs_dict","(","dict",")",":","The","keyword","args","dictionary","of","the","bbox_head","functions",",","which","is","usually","empty",",","or","includes","`","enc_outputs_class","`","and","`","enc_outputs_class","`","when","the","detector","support","'two","stage","'","or","'query","selection","'","strategies","."]
code: def pre_decoder(self, memory: Tensor) -> Tuple[Dict, Dict]:
      """Prepare intermediate variables before entering Transformer decoder,
      such as `query`, `query_pos`.
  
      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:
          memory (Tensor): The output embeddings of the Transformer encoder,
              has shape (bs, num_feat_points, dim).
  
      Returns:
          tuple[dict, dict]: The first dict contains the inputs of decoder
          and the second dict contains the inputs of the bbox_head function.
  
          - decoder_inputs_dict (dict): The keyword args dictionary of
            `self.forward_decoder()`, which includes 'query', 'query_pos',
            'memory'.
          - head_inputs_dict (dict): The keyword args dictionary of the
            bbox_head functions, which is usually empty, or includes
            `enc_outputs_class` and `enc_outputs_class` when the detector
            support 'two stage' or 'query selection' strategies.
      """
  
      batch_size = memory.size(0)  # (bs, num_feat_points, dim)
      query_pos = self.query_embedding.weight
      # (num_queries, dim) -> (bs, num_queries, dim)
      query_pos = query_pos.unsqueeze(0).repeat(batch_size, 1, 1)
      query = torch.zeros_like(query_pos)
  
      decoder_inputs_dict = dict(
          query_pos=query_pos, query=query, memory=memory
      )
      head_inputs_dict = dict()
      return decoder_inputs_dict, 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 5 for calling the DETR obj's underlying member method code with example usage: obj.pre_decoder(memory) and returns: decoder_inputs_dict,  head_inputs_dict