class_docstr: Allows the model to jointly attend to information
  from different representation subspaces.
  See reference: Attention Is All You Need
  
  .. math::
              ext{MultiHead}(Q, K, V) =       ext{Concat}(head_1,\dots,head_h)W^O
              ext{where} head_i =     ext{Attention}(QW_i^Q, KW_i^K, VW_i^V)
  
  Args:
      embed_dim: total dimension of the model
      num_heads: parallel attention layers, or heads
class_docstr_tok: ["Allows","the","model","to","jointly","attend","to","information","from","different","representation","subspaces",".","See","reference",":","Attention","Is","All","You","Need","..","math",":",":","ext","{","MultiHead","}","(","Q",",","K",",","V",")","=","ext","{","Concat","}","(","head_1",",","\\dots",",","head_h",")","W^O","ext","{","where","}","head_i","=","ext","{","Attention","}","(","QW_i^Q",",","KW_i^K",",","VW_i^V",")","Args",":","embed_dim",":","total","dimension","of","the","model","num_heads",":","parallel","attention","layers",",","or","heads"]
code: def __init__(
      self, embed_dim, num_heads, dropout=0.0, self_attn=False
  ):
      super(MultiheadAttention, self).__init__()
      self.embed_dim = embed_dim
      self.num_heads = num_heads
      # self.dropout = dropout
      self.head_dim = embed_dim // num_heads
      assert (
          self.head_dim * num_heads == self.embed_dim
      ), "embed_dim must be divisible by num_heads"
      self.scale = self.head_dim**-0.5
      self.self_attn = self_attn
      if self_attn:
          self.qkv = nn.Linear(embed_dim, embed_dim * 3)
      else:
          self.q = nn.Linear(embed_dim, embed_dim)
          self.kv = nn.Linear(embed_dim, embed_dim * 2)
      self.attn_drop = nn.Dropout(dropout)
      self.out_proj = nn.Linear(embed_dim, embed_dim)
  
imports: import math
  import paddle
  from paddle import nn
  import paddle.nn.functional
  from paddle.nn import LayerList
  from paddle.nn import Dropout, Linear, LayerNorm
  import numpy
  from ppocr.modeling.backbones.rec_svtrnet import Mlp, zeros_, ones_
  from paddle.nn.initializer import XavierNormal
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, _attn)