code: def test_hybridstack():
      cell = gluon.rnn.HybridSequentialRNNCell()
      for i in range(5):
          if i == 1:
              cell.add(gluon.rnn.ResidualCell(gluon.rnn.LSTMCell(100)))
          else:
              cell.add(gluon.rnn.LSTMCell(100))
      inputs = [mx.np.ones((10, 50)) for i in range(3)]
      cell.infer_shape(0, inputs[0], False)
      cell.initialize()
      outputs, _ = cell.unroll(3, inputs)
      keys = sorted(cell.collect_params().keys())
      for i in range(5):
          if i == 1:
              continue
          assert f"{i}.h2h_weight" in keys
          assert f"{i}.h2h_bias" in keys
          assert f"{i}.i2h_weight" in keys
          assert f"{i}.i2h_bias" in keys
      assert "1.base_cell.h2h_weight" in keys
      assert "1.base_cell.h2h_bias" in keys
      assert "1.base_cell.i2h_weight" in keys
      assert "1.base_cell.i2h_bias" in keys
  
      outs = [o.shape for o in outputs]
      assert outs == [(10, 100), (10, 100), (10, 100)]
  
      # Test HybridSequentialRNNCell nested in nn.HybridBlock, SequentialRNNCell will fail in this case
      class BidirectionalOfSequential(gluon.HybridBlock):
          def __init__(self):
              super(BidirectionalOfSequential, self).__init__()
  
              cell0 = gluon.rnn.HybridSequentialRNNCell()
              cell0.add(gluon.rnn.LSTMCell(100))
              cell0.add(gluon.rnn.LSTMCell(100))
  
              cell1 = gluon.rnn.HybridSequentialRNNCell()
              cell1.add(gluon.rnn.LSTMCell(100))
              cell1.add(gluon.rnn.LSTMCell(100))
  
              self.rnncell = gluon.rnn.BidirectionalCell(cell0, cell1)
  
          def forward(self, x):
              return self.rnncell.unroll(
                  3, x, layout="NTC", merge_outputs=True
              )
  
          def infer_shape(self, x, *args):
              self.rnncell.infer_shape(0, x, True)
  
      x = mx.np.random.uniform(size=(10, 3, 100))
      net = BidirectionalOfSequential()
      net.infer_shape(x)
      net.initialize()
      outs, _ = net(x)
  
      assert outs.shape == (10, 3, 200)
  
imports: import mxnet
  from mxnet import gluon, np
  import numpy
  import copy
  from functools import partial
  from numpy.testing import assert_allclose
  from mxnet.gluon.utils import split_rnn_params
  import pytest
  from mxnet.test_utils import almost_equal, assert_almost_equal, default_device
  from common import assert_raises_cudnn_not_satisfied, retry
label_desc: Use image node_id 10 for calling a global function with example usage: test_hybridstack() and returns: self