code: def test_dot_product_attention(scaled, normalized, ctx):
      with ctx:
          num_heads = 4
          batch_size = 32
          query_length, mem_length = 16, 32
          num_channel = 8
          query = mx.np.random.normal(
              0, 1, (batch_size, num_heads, query_length, num_channel)
          )
          key = mx.np.random.normal(
              0, 1, (batch_size, num_heads, mem_length, num_channel)
          )
          value = mx.np.random.normal(
              0, 1, (batch_size, num_heads, mem_length, num_channel)
          )
          mask = mx.np.random.randint(
              0, 2, (batch_size, query_length, mem_length)
          )
          out, [score, attn_weights] = multi_head_dot_attn(
              query,
              key,
              value,
              mask,
              query_head_units=num_channel,
              scaled=scaled,
              normalized=normalized,
          )
          assert out.shape == (
              batch_size,
              query_length,
              num_heads * num_channel,
          )
          for i in range(num_heads):
              assert_allclose(
                  attn_weights[:, i, :, :][mask == 0].asnumpy(),
                  mask[mask == 0].astype(np.float32).asnumpy(),
                  1e-5,
                  1e-5,
              )
  
file_path: gluon-nlp/tests/test_attention_cell.py
imports: import numpy
  from numpy.testing import assert_allclose
  import pytest
  import mxnet
  from mxnet.gluon import HybridBlock
  from gluonnlp.attention_cell import multi_head_dot_attn, gen_self_attn_mask, gen_mem_attn_mask, MultiHeadAttentionCell, RelAttentionScoreCell
  from gluonnlp.utils.parameter import grad_global_norm
label_desc: Use image node_id 2 for calling a global function with example usage: test_dot_product_attention(scaled, normalized, ctx) without return types