code: def compute_lengths(batch_sizes):
      tmp_batch_sizes = np.copy(batch_sizes)
      lengths = []
      while True:
          c = np.count_nonzero(tmp_batch_sizes > 0)
          if c == 0:
              break
          lengths.append(c)
          tmp_batch_sizes = np.array([b - 1 for b in tmp_batch_sizes])
      return np.array(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 1 for calling a global function with example usage: compute_lengths(batch_sizes) and returns: np