code: def test_layer_bidirectional():
      class RefBiLSTM(gluon.Block):
          def __init__(self, size, **kwargs):
              super(RefBiLSTM, self).__init__(**kwargs)
              self._lstm_fwd = gluon.rnn.LSTM(size, bidirectional=False)
              self._lstm_bwd = gluon.rnn.LSTM(size, bidirectional=False)
  
          def forward(self, inpt):
              fwd = self._lstm_fwd(inpt)
              bwd_inpt = np.flip(inpt, 0)
              bwd = self._lstm_bwd(bwd_inpt)
              bwd = np.flip(bwd, 0)
              return np.concatenate([fwd, bwd], axis=2)
  
      size = 7
      in_size = 5
      weights = {}
      for d in ["l", "r"]:
          weights["{}0_i2h_weight".format(d)] = mx.np.random.uniform(
              size=(size * 4, in_size)
          )
          weights["{}0_h2h_weight".format(d)] = mx.np.random.uniform(
              size=(size * 4, size)
          )
          weights["{}0_i2h_bias".format(d)] = mx.np.random.uniform(
              size=(size * 4,)
          )
          weights["{}0_h2h_bias".format(d)] = mx.np.random.uniform(
              size=(size * 4,)
          )
  
      params = (
          weights["{}0_{}_{}".format(d, g, t)].reshape(-1)
          for t in ["weight", "bias"]
          for d in ["l", "r"]
          for g in ["i2h", "h2h"]
      )
      net_params_concat = mx.np.concatenate(params)
      params_left = (
          weights["l0_{}_{}".format(g, t)].reshape(-1)
          for t in ["weight", "bias"]
          for g in ["i2h", "h2h"]
      )
      params_right = (
          weights["r0_{}_{}".format(g, t)].reshape(-1)
          for t in ["weight", "bias"]
          for g in ["i2h", "h2h"]
      )
      net_ref_left_params = mx.np.concatenate(params_left)
      net_ref_right_params = mx.np.concatenate(params_right)
      net = gluon.rnn.LSTM(size, bidirectional=True)
      ref_net = RefBiLSTM(size)
      net.initialize()
      ref_net.initialize()
      net_params = net.collect_params()
      ref_net_params = ref_net.collect_params()
      net_params["rnn_param"].set_data(net_params_concat)
      ref_net_params["_lstm_fwd.rnn_param"].set_data(
          net_ref_left_params
      )
      ref_net_params["_lstm_bwd.rnn_param"].set_data(
          net_ref_right_params
      )
  
      data = mx.np.random.uniform(size=(11, 10, in_size))
      assert_allclose(
          net(data).asnumpy(),
          ref_net(data).asnumpy(),
          rtol=1e-04,
          atol=1e-02,
      )
  
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 12 for calling a global function with example usage: test_layer_bidirectional() and returns: np