code: def test_bidirectional_unroll_valid_length():
      def _check_bidirectional_unroll_valid_length(length):
          class BiLSTM(gluon.nn.HybridBlock):
              def __init__(self, rnn_size, time_step, **kwargs):
                  super(BiLSTM, self).__init__(**kwargs)
                  self.time_step = time_step
                  self.bi_lstm = gluon.rnn.BidirectionalCell(
                      gluon.rnn.LSTMCell(rnn_size),
                      gluon.rnn.LSTMCell(rnn_size),
                  )
  
              def forward(self, inputs, valid_len):
                  outputs, states = self.bi_lstm.unroll(
                      self.time_step,
                      inputs,
                      valid_length=valid_len,
                      layout="NTC",
                      merge_outputs=True,
                  )
                  return outputs, states
  
              def infer_shape(self, x, *args):
                  self.bi_lstm.infer_shape(0, x, True)
  
          rnn_size = 100
          net = BiLSTM(rnn_size, length)
          inputs_data = mx.np.random.uniform(size=(10, length, 50))
          net.infer_shape(inputs_data)
          net.initialize()
          net.hybridize()
          valid_len = mx.np.array([length] * 10)
          outputs, _ = net(inputs_data, valid_len)
          assert outputs.shape == (10, length, 200)
  
      _check_bidirectional_unroll_valid_length(1)
      _check_bidirectional_unroll_valid_length(3)
  
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 31 for calling a global function with example usage: test_bidirectional_unroll_valid_length() and returns: outputs,  states