class_docstr: Implements the DETR transformer.
  
  Following the official DETR implementation, this module copy-paste
  from torch.nn.Transformer with modifications:
  
      * positional encodings are passed in MultiheadAttention
      * extra LN at the end of encoder is removed
      * decoder returns a stack of activations from all decoding layers
  
  See `paper: End-to-End Object Detection with Transformers
  <https://arxiv.org/pdf/2005.12872>`_ for details.
  
  Args:
      encoder (`mmcv.ConfigDict` | Dict): Config of
          TransformerEncoder. Defaults to None.
      decoder ((`mmcv.ConfigDict` | Dict)): Config of
          TransformerDecoder. Defaults to None
      init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization.
          Defaults to None.
class_docstr_tok: ["Implements","the","DETR","transformer",".","Following","the","official","DETR","implementation",",","this","module","copy-paste","from","torch.nn.Transformer","with","modifications",":","*","positional","encodings","are","passed","in","MultiheadAttention","*","extra","LN","at","the","end","of","encoder","is","removed","*","decoder","returns","a","stack","of","activations","from","all","decoding","layers","See","`","paper",":","End-to-End","Object","Detection","with","Transformers","<","https",":","\/\/arxiv.org\/pdf\/2005.12872",">","`","_","for","details",".","Args",":","encoder","(","`","mmcv.ConfigDict","`","|","Dict",")",":","Config","of","TransformerEncoder",".","Defaults","to","None",".","decoder","(","(","`","mmcv.ConfigDict","`","|","Dict",")",")",":","Config","of","TransformerDecoder",".","Defaults","to","None","init_cfg","(","obj",":","`","mmcv.ConfigDict","`",")",":","The","Config","for","initialization",".","Defaults","to","None","."]
code: def init_weights(self):
      # follow the official DETR to init parameters
      for m in self.modules():
          if hasattr(m, "weight") and m.weight.dim() > 1:
              xavier_init(m, distribution="uniform")
      self._is_init = True
  
imports: import math
  import warnings
  from typing import Sequence
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from mmcv.cnn import Linear, build_activation_layer, build_norm_layer, xavier_init
  from mmcv.cnn.bricks.drop import build_dropout
  from mmcv.cnn.bricks.registry import FEEDFORWARD_NETWORK, TRANSFORMER_LAYER, TRANSFORMER_LAYER_SEQUENCE
  from mmcv.cnn.bricks.transformer import BaseTransformerLayer, TransformerLayerSequence, build_transformer_layer_sequence
  from mmcv.runner.base_module import BaseModule, Sequential
  from mmcv.utils import deprecated_api_warning, to_2tuple
  from torch.nn.init import normal_
  from ..builder import TRANSFORMER
label_desc: Use image node_id 2 for calling the Transformer obj's underlying member method code with example usage: obj.init_weights() without return types