code: def test_dynamic_decode_rnn_with_training_helper_matches_dynamic_rnn(
      use_sequence_length,
  ):
      sequence_length = [3, 4, 3, 1, 0]
      batch_size = 5
      max_time = 8
      input_depth = 7
      cell_depth = 10
      max_out = max(sequence_length)
  
      inputs = np.random.randn(
          batch_size, max_time, input_depth
      ).astype(np.float32)
      inputs = tf.constant(inputs)
  
      cell = tf.keras.layers.LSTMCell(cell_depth)
      zero_state = cell.get_initial_state(
          batch_size=batch_size, dtype=tf.float32
      )
      sampler = sampler_py.TrainingSampler()
      my_decoder = basic_decoder.BasicDecoder(
          cell=cell,
          sampler=sampler,
          impute_finished=use_sequence_length,
      )
  
      (final_decoder_outputs, final_decoder_state, _) = my_decoder(
          inputs,
          initial_state=zero_state,
          sequence_length=sequence_length,
      )
  
      rnn = tf.keras.layers.RNN(
          cell, return_sequences=True, return_state=True
      )
      mask = (
          tf.sequence_mask(sequence_length, maxlen=max_time)
          if use_sequence_length
          else None
      )
      outputs = rnn(inputs, mask=mask, initial_state=zero_state)
      final_rnn_outputs = outputs[0]
      final_rnn_state = outputs[1:]
      if use_sequence_length:
          final_rnn_outputs *= tf.cast(
              tf.expand_dims(mask, -1), final_rnn_outputs.dtype
          )
  
      # Decoder only runs out to max_out; ensure values are identical
      # to dynamic_rnn, which also zeros out outputs and passes along
      # state.
      np.testing.assert_allclose(
          final_decoder_outputs.rnn_output,
          final_rnn_outputs[:, 0:max_out, :],
      )
      if use_sequence_length:
          np.testing.assert_allclose(
              final_decoder_state, final_rnn_state
          )
  
file_path: addons/tensorflow_addons/seq2seq/tests/decoder_test.py
imports: import numpy
  import pytest
  import tensorflow
  from tensorflow_addons.seq2seq import basic_decoder
  from tensorflow_addons.seq2seq import decoder
  from tensorflow_addons.seq2seq import sampler
  from tensorflow_addons.utils import test_utils
label_desc: Use image node_id 3 for calling a global function with example usage: test_dynamic_decode_rnn_with_training_helper_matches_dynamic_rnn(use_sequence_length) without return types