code: def test_custom_attention_layer():
      dummy_data = DummyData2()
      attention_mechanism = wrapper.LuongAttention(dummy_data.units)
      cell = tf.keras.layers.LSTMCell(dummy_data.units)
      attention_layer = tf.keras.layers.Dense(
          dummy_data.units * 2, use_bias=False, activation=tf.math.tanh
      )
      attention_wrapper = wrapper.AttentionWrapper(
          cell, attention_mechanism, attention_layer=attention_layer
      )
      with pytest.raises(ValueError):
          # Should fail because the attention mechanism has not been
          # initialized.
          attention_wrapper.get_initial_state(
              batch_size=dummy_data.batch, dtype=tf.float32
          )
      attention_mechanism.setup_memory(
          dummy_data.encoder_outputs.astype(np.float32),
          memory_sequence_length=dummy_data.encoder_sequence_length,
      )
      initial_state = attention_wrapper.get_initial_state(
          batch_size=dummy_data.batch, dtype=tf.float32
      )
      assert initial_state.attention.shape[-1] == dummy_data.units * 2
      first_input = dummy_data.decoder_inputs[:, 0].astype(np.float32)
      output, _ = attention_wrapper(first_input, initial_state)
      assert output.shape[-1] == dummy_data.units * 2
  
imports: import collections
  from packaging.version import Version
  import pytest
  import numpy
  import tensorflow
  from tensorflow_addons.seq2seq import attention_wrapper
  from tensorflow_addons.seq2seq import basic_decoder
  from tensorflow_addons.seq2seq import sampler
label_desc: Use image node_id 11 for calling a global function with example usage: test_custom_attention_layer() without return types