code: def test_dynamic_rnn(self):
      batch_size = 3
      num_steps = 5
      embedding_size = 6
  
      hidden_size = 4
      inputs = tl.layers.Input([batch_size, num_steps, embedding_size])
  
      rnn_layer = tl.layers.RNN(
          cell=tf.keras.layers.LSTMCell(units=hidden_size, dropout=0.1),
          in_channels=embedding_size,
          return_last_output=True,
          return_last_state=True,
      )
  
      rnn_layer.is_train = False
  
      print(tl.layers.retrieve_seq_length_op3(inputs))
      _ = rnn_layer(
          inputs,
          sequence_length=tl.layers.retrieve_seq_length_op3(inputs),
      )
      _ = rnn_layer(inputs, sequence_length=np.array([5, 5, 5]))
  
      # test exceptions
      except_flag = False
      try:
          _ = rnn_layer(inputs, sequence_length=1)
          except_flag = True
      except TypeError as e:
          print(e)
  
      try:
          _ = rnn_layer(inputs, sequence_length=["str", 1, 2])
          except_flag = True
      except TypeError as e:
          print(e)
  
      try:
          _ = rnn_layer(inputs, sequence_length=[10, 2, 2])
          except_flag = True
      except ValueError as e:
          print(e)
  
      try:
          _ = rnn_layer(inputs, sequence_length=[1])
          except_flag = True
      except ValueError as e:
          print(e)
  
      if except_flag:
          self.fail("Exception not detected.")
  
      # test warning
      for _ in range(5):
          _ = rnn_layer(
              inputs,
              sequence_length=[5, 5, 5],
              return_last_output=False,
              return_last_state=True,
          )
          _ = rnn_layer(
              inputs,
              sequence_length=[5, 5, 5],
              return_last_output=True,
              return_last_state=False,
          )
  
      x = rnn_layer(
          inputs,
          sequence_length=None,
          return_last_output=True,
          return_last_state=True,
      )
      y = rnn_layer(
          inputs,
          sequence_length=[5, 5, 5],
          return_last_output=True,
          return_last_state=True,
      )
  
      assert len(x) == 2
      assert len(y) == 2
  
      for i, j in zip(x, y):
          self.assertTrue(np.allclose(i, j))
  
imports: import os
  import unittest
  import numpy
  import tensorflow
  import tensorlayer
  from tests.utils import CustomTestCase
label_desc: Use image node_id 28 for calling the Layer_RNN_Test obj's underlying member method code with example usage: obj.test_dynamic_rnn() without return types