code: def check_forward(self, h_data, xs_data):
      if self.hidden_none:
          h = None
      else:
          h = chainer.Variable(h_data)
      xs = [chainer.Variable(x) for x in xs_data]
      hy, ys = self.rnn(h, xs)
  
      assert hy.shape == h_data.shape
      assert len(xs) == len(ys)
      for x, y in zip(xs, ys):
          assert len(x) == len(y)
          assert y.shape[1] == self.out_size * 2
  
      with testing.assert_warns(DeprecationWarning):
          self.rnn.to_cpu()
  
      for batch, seq in enumerate(self.xs):
          for layer in range(self.n_layers):
              # forward
              di = 0
              layer_idx = layer * 2 + di
              p = self.rnn[layer_idx]
              h_prev = self.h[layer_idx, batch]
              hs_f = []
              for x in seq:
                  if self.activation == "tanh":
                      activation_func = numpy.tanh
                  elif self.activation == "relu":
                      activation_func = relu
  
                  h_prev = activation_func(
                      x.dot(p.w0.array.T)
                      + h_prev.dot(p.w1.array.T)
                      + p.b0.array
                      + p.b1.array
                  )
                  hs_f.append(h_prev)
  
              testing.assert_allclose(
                  hy.array[layer_idx, batch], h_prev
              )
  
              # backward
              di = 1
              layer_idx = layer * 2 + di
              p = self.rnn[layer_idx]
              h_prev = self.h[layer_idx, batch]
              hs_b = []
              for x in reversed(seq):
                  if self.activation == "tanh":
                      activation_func = numpy.tanh
                  elif self.activation == "relu":
                      activation_func = relu
                  h_prev = activation_func(
                      x.dot(p.w0.array.T)
                      + h_prev.dot(p.w1.array.T)
                      + p.b0.array
                      + p.b1.array
                  )
                  hs_b.append(h_prev)
              testing.assert_allclose(hy.data[layer_idx, batch], h_prev)
  
              hs_b.reverse()
              seq = [
                  numpy.concatenate([hfi, hbi], axis=0)
                  for (hfi, hbi) in zip(hs_f, hs_b)
              ]
  
          for y, ey in zip(ys[batch].array, seq):
              testing.assert_allclose(y, ey)
  
imports: import unittest
  import numpy
  import chainer
  from chainer.backends import cuda
  from chainer import gradient_check
  from chainer import links
  from chainer import testing
  from chainer import initializers
  from chainer.testing import attr
  from chainer.testing import condition
label_desc: Use image node_id 2 for calling the TestNStepBiRNN obj's underlying member method code with example usage: obj.check_forward(h_data, xs_data) without return types