docstr: :param embed_dim: 输入的维度，必须能被 num_heads 整除
  :param num_heads: attention 的个数
  :param dropout: float。
code: def __init__(
      self, embed_dim, num_heads, dropout=0.0, output_attentions=True
  ):
      """
      :param embed_dim: 输入的维度，必须能被 num_heads 整除
      :param num_heads: attention 的个数
      :param dropout: float。
      """
      super(MultiHeadAttention, self).__init__()
      self.num_heads = num_heads
      self.output_attentions = output_attentions
      self.head_dim = int(embed_dim / num_heads)
      self.all_head_dim = self.head_dim * num_heads
      assert self.all_head_dim == embed_dim, logger.error(
          f"embed_dim{embed_dim} must be divisible by num_heads{num_heads}"
      )
  
      self.q_in = nn.Linear(embed_dim, self.all_head_dim)
      self.k_in = nn.Linear(embed_dim, self.all_head_dim)
      self.v_in = nn.Linear(embed_dim, self.all_head_dim)
      self.attention = DotAttention(dropout=dropout)
      self.out = nn.Linear(self.all_head_dim, embed_dim)
  
file_path: DeepKE/src/deepke/relation_extraction/standard/module/Attention.py
imports: import logging
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new MultiHeadAttention object from inherited base classes: nn with example: obj = MultiHeadAttention(embed_dim, num_heads, dropout, output_attentions)