class_docstr: Multi-Head Attention
class_docstr_tok: ["Multi-Head","Attention"]
code: def forward(self, queries, keys, values, attn_bias, cache=None):
      # compute q ,k ,v
      keys = queries if keys is None else keys
      values = keys if values is None else values
      q, k, v = self._prepare_qkv(queries, keys, values, cache)
  
      # scale dot product attention
      product = paddle.matmul(x=q, y=k, transpose_y=True)
      product = product * self.d_model**-0.5
      if attn_bias is not None:
          product += attn_bias
      weights = F.softmax(product)
      if self.dropout_rate:
          weights = F.dropout(
              weights, p=self.dropout_rate, mode="downscale_in_infer"
          )
      out = paddle.matmul(weights, v)
  
      # combine heads
      out = paddle.transpose(out, perm=[0, 2, 1, 3])
      out = paddle.reshape(
          x=out, shape=[0, 0, out.shape[2] * out.shape[3]]
      )
  
      # project to output
      out = self.proj_fc(out)
  
      return out
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import paddle
  from paddle import ParamAttr, nn
  from paddle import nn, ParamAttr
  from paddle.nn import functional
  import numpy
label_desc: Use image node_id 3 for calling the MultiHeadAttention obj's underlying member method code with example usage: obj.forward(queries, keys, values, attn_bias, cache) and returns: out