code: def check_rnn(cell_type, num_states):
      batch_size = 10
      hidden_size = 100
      rnn_data = mx.np.random.normal(
          loc=0, scale=1, size=(5, batch_size, 50)
      )
      state_shape = (batch_size, hidden_size)
      states = [
          mx.np.random.normal(loc=0, scale=1, size=state_shape)
          for i in range(num_states)
      ]
      layer = RNNLayer(cell_type, hidden_size)
      layer.infer_shape(rnn_data)
      layer.initialize(device=default_device())
      res1 = layer(rnn_data, states)
      params1 = layer.collect_params()
      orig_params1 = copy.deepcopy(params1)
  
      trainer = gluon.Trainer(params1, "sgd", {"learning_rate": 0.03})
      with mx.autograd.record():
          res1 = layer(rnn_data, states)
      res1.backward()
      trainer.step(batch_size)
  
      configs = [
          {},
          {"inline_limit": 0},
          {"static_alloc": True},
          {"static_alloc": True, "static_shape": True},
      ]
      for config in configs:
          layer = RNNLayer(cell_type, hidden_size)
          layer.infer_shape(rnn_data)
          layer.initialize(device=default_device())
          layer.hybridize(**config)
          res2 = layer(rnn_data, states)
          params2 = layer.collect_params()
          for key, val in orig_params1.items():
              params2[key].set_data(copy.deepcopy(val.data()))
          trainer = gluon.Trainer(
              params2, "sgd", {"learning_rate": 0.03}
          )
          with mx.autograd.record():
              res2 = layer(rnn_data, states)
          assert_almost_equal(
              res1.asnumpy(), res2.asnumpy(), rtol=1e-3, atol=1e-3
          )
          res2.backward()
          trainer.step(batch_size)
  
          for key, val in params1.items():
              weight1 = val.data()
              weight2 = params2[key].data()
              assert_almost_equal(
                  weight1.asnumpy(),
                  weight2.asnumpy(),
                  rtol=1e-3,
                  atol=1e-3,
              )
  
imports: import copy
  import numpy
  import mxnet
  from mxnet import gluon
  from mxnet.test_utils import *
  from mxnet.base import _as_list
  from collections import defaultdict
  from mxnet.attribute import AttrScope
label_desc: Use image node_id 10 for calling a global function with example usage: check_rnn(cell_type, num_states) without return types