code: def test_rnn_parsing(rnn_layer, return_sequences):
      time_steps = 3
      input_size = 8
      input_shape = (time_steps, input_size)
  
      model_input = Input(shape=input_shape)
      model_output = rnn_layer(64, return_sequences=return_sequences)(
          model_input
      )
  
      model = Model(model_input, model_output)
      model.compile(optimizer="adam", loss="mse")
  
      config = hls4ml.utils.config_from_keras_model(
          model, granularity="name"
      )
      prj_name = f"hls4mlprj_rnn_{rnn_layer.__class__.__name__.lower()}_seq_{int(return_sequences)}"
      output_dir = str(test_root_path / prj_name)
      hls_model = hls4ml.converters.convert_from_keras_model(
          model, hls_config=config, output_dir=output_dir
      )
  
      hls_layer = list(hls_model.get_layers())[
          1
      ]  # 0 is input, 1 is the RNN layer
      keras_layer = model.layers[1]
  
      # Basic sanity check, I/O, activations
      assert hls_layer.class_name == rnn_layer.__name__
      assert hls_layer.attributes["n_out"] == keras_layer.units
      assert (
          hls_layer.attributes["activation"]
          == keras_layer.activation.__name__
      )
      if (
          "recurrent_activation" in hls_layer.attributes
      ):  # SimpleRNN doesn't have this
          assert (
              hls_layer.attributes["recurrent_activation"]
              == keras_layer.recurrent_activation.__name__
          )
      assert hls_layer.get_input_variable().shape == list(input_shape)
      assert (
          hls_layer.get_output_variable().shape
          == model_output.shape.as_list()[1:]
      )  # Ignore the batch size
  
      # Compare weights
      hls_weights = list(
          hls_layer.get_weights()
      )  # [weights, recurrent_weights, bias, recurrent_bias]
      rnn_weights = (
          keras_layer.get_weights()
      )  # [weights, recurrent_weights, bias]
  
      assert hls_weights[0].data.shape == rnn_weights[0].shape
      assert hls_weights[1].data.shape == rnn_weights[1].shape
      if "gru" in rnn_layer.__name__.lower():
          # GRU has both bias and recurrent bias
          assert hls_weights[2].data.shape == rnn_weights[2][0].shape
          assert hls_weights[3].data.shape == rnn_weights[2][1].shape
      else:
          # LSTM and SimpleRNN only have bias
          assert hls_weights[2].data.shape == rnn_weights[2].shape
  
      np.testing.assert_array_equal(hls_weights[0].data, rnn_weights[0])
      np.testing.assert_array_equal(hls_weights[1].data, rnn_weights[1])
      if "gru" in rnn_layer.__name__.lower():
          np.testing.assert_array_equal(
              hls_weights[2].data, rnn_weights[2][0]
          )
          np.testing.assert_array_equal(
              hls_weights[3].data, rnn_weights[2][1]
          )
      else:
          np.testing.assert_array_equal(
              hls_weights[2].data, rnn_weights[2]
          )
  
file_path: hls4ml/test/pytest/test_rnn.py
imports: from pathlib import Path
  import numpy
  import pytest
  from tensorflow.keras.layers import GRU, LSTM, Input, SimpleRNN
  from tensorflow.keras.models import Model, Sequential
  import hls4ml
label_desc: Use image node_id 1 for calling a global function with example usage: test_rnn_parsing(rnn_layer, return_sequences) without return types