code: def forward(self, queries, keys, values, attn_bias, past_cache):
      assert (
          len(queries.shape)
          == len(keys.shape)
          == len(values.shape)
          == 3
      )
  
      q = self.q(queries)
      k = self.k(keys)
      v = self.v(values)
  
      cache = (k, v)
      if past_cache is not None:
          cached_k, cached_v = past_cache
          k = L.concat([cached_k, k], 1)
          v = L.concat([cached_v, v], 1)
  
      q = L.transpose(
          L.reshape(q, [0, 0, self.n_head, q.shape[-1] // self.n_head]),
          [0, 2, 1, 3],
      )  # [batch, head, seq, dim]
      k = L.transpose(
          L.reshape(k, [0, 0, self.n_head, k.shape[-1] // self.n_head]),
          [0, 2, 1, 3],
      )  # [batch, head, seq, dim]
      v = L.transpose(
          L.reshape(v, [0, 0, self.n_head, v.shape[-1] // self.n_head]),
          [0, 2, 1, 3],
      )  # [batch, head, seq, dim]
  
      q = L.scale(q, scale=self.d_key**-0.5)
      score = L.matmul(q, k, transpose_y=True)
      if attn_bias is not None:
          score += attn_bias
      score = L.softmax(score, use_cudnn=True)
      score = self.dropout(score)
  
      out = L.matmul(score, v)
      out = L.transpose(out, [0, 2, 1, 3])
      out = L.reshape(out, [0, 0, out.shape[2] * out.shape[3]])
  
      out = self.o(out)
      return out, cache
  
imports: from __future__ import division
  from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import unicode_literals
  import logging
  import paddle.fluid.dygraph
  import paddle.fluid
  import paddle.fluid.layers
label_desc: Use image node_id 2 for calling the AttentionLayer obj's underlying member method code with example usage: obj.forward(queries, keys, values, attn_bias, past_cache) and returns: out,  cache