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: Mask operation used in multi-head self attention
  
  Args:
      seq_len (object): sequence length of inputs.
      mode (str): mode of mask.
  
  Returns:
      object: tensors after masking.
docstr_tok: ["Mask","operation","used","in","multi-head","self","attention","Args",":","seq_len","(","object",")",":","sequence","length","of","inputs",".","mode","(","str",")",":","mode","of","mask",".","Returns",":","object",":","tensors","after","masking","."]
code: def Mask(self, inputs, seq_len, mode="add"):
      """Mask operation used in multi-head self attention
  
      Args:
          seq_len (object): sequence length of inputs.
          mode (str): mode of mask.
  
      Returns:
          object: tensors after masking.
      """
  
      if seq_len is None:
          return inputs
      else:
          mask = K.one_hot(
              indices=seq_len[:, 0], num_classes=K.shape(inputs)[1]
          )
          mask = 1 - K.cumsum(mask, axis=1)
  
          for _ in range(len(inputs.shape) - 2):
              mask = K.expand_dims(mask, 2)
  
          if mode == "mul":
              return inputs * mask
          elif mode == "add":
              return inputs - (1 - mask) * 1e12
  
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 4 for calling the SelfAttention obj's underlying member method code with example usage: obj.Mask(inputs, seq_len, mode) and returns: inputs, unknown, unknown