code: def test_script_rnn_layer(seq_len, batch, input_size, hidden_size):
      inp = torch.randn(seq_len, batch, input_size)
      state = LSTMState(
          torch.randn(batch, hidden_size),
          torch.randn(batch, hidden_size),
      )
      rnn = LSTMLayer(LSTMCell, input_size, hidden_size)
      out, out_state = rnn(inp, state)
  
      # Control: pytorch native LSTM
      lstm = nn.LSTM(input_size, hidden_size, 1)
      lstm_state = LSTMState(
          state.hx.unsqueeze(0), state.cx.unsqueeze(0)
      )
      for lstm_param, custom_param in zip(
          lstm.all_weights[0], rnn.parameters()
      ):
          assert lstm_param.shape == custom_param.shape
          with torch.no_grad():
              lstm_param.copy_(custom_param)
      lstm_out, lstm_out_state = lstm(inp, lstm_state)
  
      assert (out - lstm_out).abs().max() < 1e-5
      assert (out_state[0] - lstm_out_state[0]).abs().max() < 1e-5
      assert (out_state[1] - lstm_out_state[1]).abs().max() < 1e-5
  
imports: import numbers
  import warnings
  from collections import namedtuple
  from typing import List, Tuple
  import torch
  import torch.jit
  import torch.nn
  from torch import Tensor
  from torch.nn import Parameter
label_desc: Use image node_id 7 for calling a global function with example usage: test_script_rnn_layer(seq_len, batch, input_size, hidden_size) without return types