class_docstr: Multi-head self attention implement.
  
  Args:
      multiheads (int): The number of heads.
      head_dim (object): Dimention of each head.
      mask_right (boolean): whether to mask right words.
  
  Returns:
      object: Weighted sum after attention.
docstr: Initialization steps for AttLayer2.
  
  Args:
      multiheads (int): The number of heads.
      head_dim (object): Dimension of each head.
      mask_right (boolean): Whether to mask right words.
docstr_tok: ["Initialization","steps","for","AttLayer2",".","Args",":","multiheads","(","int",")",":","The","number","of","heads",".","head_dim","(","object",")",":","Dimension","of","each","head",".","mask_right","(","boolean",")",":","Whether","to","mask","right","words","."]
code: def __init__(
      self, multiheads, head_dim, seed=0, mask_right=False, **kwargs
  ):
      """Initialization steps for AttLayer2.
  
      Args:
          multiheads (int): The number of heads.
          head_dim (object): Dimension of each head.
          mask_right (boolean): Whether to mask right words.
      """
  
      self.multiheads = multiheads
      self.head_dim = head_dim
      self.output_dim = multiheads * head_dim
      self.mask_right = mask_right
      self.seed = seed
      super(SelfAttention, self).__init__(**kwargs)
  
imports: import tensorflow.compat.v1.keras
  from tensorflow.compat.v1.linalg import einsum
  from tensorflow.compat.v1.keras import layers
  from tensorflow.compat.v1.keras import backend
label_desc: Use image node_id 1 to create a new SelfAttention object from inherited base classes: layers with example: obj = SelfAttention(multiheads, head_dim, seed, mask_right)