code: def test_pack_and_unpack(
      total_length,
      enforce_sorted,
      batch_first,
      shapes,
      seed,
      ctx,
      func_name,
  ):
      rng = np.random.RandomState(seed)
  
      sequences = [
          rng.randn(*shape).astype(np.float32) for shape in shapes
      ]
      if not enforce_sorted:
          indices = rng.permutation(len(sequences))
          sequences = [sequences[i] for i in indices]
      sequences = [nn.Variable.from_numpy_array(s) for s in sequences]
  
      with nn.context_scope(ctx), nn.auto_forward():
          padded_sequence0 = rnn_utils.pad_sequence(
              sequences, batch_first
          )
          packed_sequence = rnn_utils.pack_sequence(
              sequences, batch_first, enforce_sorted
          )
          padded_sequence, _ = rnn_utils.pad_packed_sequence(
              packed_sequence, batch_first, total_length
          )
          if total_length is not None:
              batch_sizes = packed_sequence.batch_sizes
              T = batch_sizes.shape[0]
              padded_sequence = (
                  padded_sequence[:, :T, ...]
                  if batch_first
                  else padded_sequence[:T, :, ...]
              )
  
          np.testing.assert_allclose(
              padded_sequence0.d, padded_sequence.d
          )
  
imports: import pytest
  import nnabla
  import nnabla.functions
  import numpy
  import nnabla.utils.rnn
  from nbla_test_utils import list_context
label_desc: Use image node_id 1 for calling a global function with example usage: test_pack_and_unpack(total_length, enforce_sorted, batch_first, shapes, seed, ctx, func_name) without return types