code: def compute_batch_sizes(lengths):
      tmp_lengths = np.copy(lengths)
      batch_sizes = []
      while True:
          c = np.count_nonzero(tmp_lengths > 0)
          if c == 0:
              break
          batch_sizes.append(c)
          tmp_lengths = np.array([l - 1 for l in tmp_lengths])
      return np.array(batch_sizes)
  
file_path: nnabla/python/test/function/test_pack_padded_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_batch_sizes(lengths) and returns: np