code: def ref_pad_packed_sequence(
      packed_sequence, batch_sizes, batch_first, padding, total_length
  ):
      lengths = compute_lengths(batch_sizes)
      B = np.max(batch_sizes)
      T = len(batch_sizes)
      T0 = max(T, total_length)
      D0 = B if batch_first else T0
      D1 = T0 if batch_first else B
      Ds = (
          packed_sequence.shape[1:]
          if len(packed_sequence.shape) > 1
          else ()
      )
      padded_sequence = np.zeros((D0, D1) + Ds)
      b_prev = 0
      b_curr = 0
      for t, b in enumerate(batch_sizes):
          b_curr += b
          packed_sequence_b = packed_sequence[b_prev:b_curr]
          if batch_first:
              padded_sequence[:b, t] = packed_sequence_b
          else:
              padded_sequence[t, :b] = packed_sequence_b
          b_prev = b_curr
      return padded_sequence, lengths
  
file_path: nnabla/python/test/function/test_pad_packed_sequence.py
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context
  from refs import pad_sequence
label_desc: Use image node_id 2 for calling a global function with example usage: ref_pad_packed_sequence(packed_sequence, batch_sizes, batch_first, padding, total_length) and returns: padded_sequence,  lengths