class_docstr: A warpper for torch.nn.MultiheadAttention.
  
  This module implements MultiheadAttention with residual connection,
  and positional encoding used in DETR is also passed as input.
  
  Args:
      embed_dims (int): The embedding dimension.
      num_heads (int): Parallel attention heads. Same as
          `nn.MultiheadAttention`.
      dropout (float): A Dropout layer on attn_output_weights. Default 0.0.
class_docstr_tok: ["A","warpper","for","torch.nn.MultiheadAttention",".","This","module","implements","MultiheadAttention","with","residual","connection",",","and","positional","encoding","used","in","DETR","is","also","passed","as","input",".","Args",":","embed_dims","(","int",")",":","The","embedding","dimension",".","num_heads","(","int",")",":","Parallel","attention","heads",".","Same","as","`","nn.MultiheadAttention","`",".","dropout","(","float",")",":","A","Dropout","layer","on","attn_output_weights",".","Default","0.0","."]
code: def __init__(self, embed_dims, num_heads, dropout=0.0):
      super(MultiheadAttention, self).__init__()
      assert embed_dims % num_heads == 0, (
          "embed_dims must be "
          f"divisible by num_heads. got {embed_dims} and {num_heads}."
      )
      self.embed_dims = embed_dims
      self.num_heads = num_heads
      self.dropout = dropout
      self.attn = nn.MultiheadAttention(embed_dims, num_heads, dropout)
      self.dropout = nn.Dropout(dropout)
  
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 1 to create a new MultiheadAttention object from inherited base classes: nn with example: obj = MultiheadAttention(embed_dims, num_heads, dropout)