code: def attention(
      query, key, value, mask=None, dropout=None, attention_map=None
  ):
      d_k = query.shape[-1]
      scores = paddle.matmul(
          query, paddle.transpose(key, [0, 1, 3, 2])
      ) / math.sqrt(d_k)
  
      if mask is not None:
          scores = masked_fill(scores, mask == 0, float("-inf"))
      else:
          pass
  
      p_attn = F.softmax(scores, 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
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 4 for calling a global function with example usage: attention(query, key, value, mask, dropout, attention_map) and returns: paddle,  p_attn