code: def test_attention_coefficients_shape():
      batch_size = 10
      num_heads = 8
      head_size = 12
  
      q = tf.random.uniform((batch_size, 5, 9), dtype=np.float32)
      k = tf.random.uniform((batch_size, 7, 11), dtype=np.float32)
      v = tf.random.uniform((batch_size, 7, 13), dtype=np.float32)
  
      mha = MultiHeadAttention(
          head_size=head_size,
          num_heads=num_heads,
          return_attn_coef=True,
      )
  
      output, attn_coef = mha([q, k, v])
  
      assert attn_coef.shape[0] == batch_size
      assert attn_coef.shape[1] == num_heads
      assert attn_coef.shape[2] == q.shape[1]
      assert attn_coef.shape[3] == k.shape[1]
  
      assert output.shape[1] == q.shape[1]
      assert output.shape[2] == v.shape[2]
  
file_path: addons/tensorflow_addons/layers/tests/multihead_attention_test.py
imports: import tempfile
  from pathlib import Path
  import numpy
  import pytest
  import tensorflow
  from tensorflow_addons.layers.multihead_attention import MultiHeadAttention
label_desc: Use image node_id 6 for calling a global function with example usage: test_attention_coefficients_shape() without return types