code: def self_attention(query, key, value, mask=None, dropout=None):
      """
      Compute 'Scale Dot Product Attention'
      """
      d_k = value.shape[-1]
  
      score = paddle.matmul(
          query, key.transpose([0, 1, 3, 2]) / math.sqrt(d_k)
      )
      if mask is not None:
          # score = score.masked_fill(mask == 0, -1e9) # b, h, L, L
          score = masked_fill(score, mask == 0, -6.55e4)  # for fp16
  
      p_attn = F.softmax(score, axis=-1)
  
      if dropout is not None:
          p_attn = dropout(p_attn)
      return paddle.matmul(p_attn, value), p_attn
  
imports: import copy
  import math
  import paddle
  from paddle import nn
  from paddle.nn import functional
label_desc: Use image node_id 2 for calling a global function with example usage: self_attention(query, key, value, mask, dropout) and returns: paddle,  p_attn