code: def test_sortagrad(swap_io):
      dummy_json = make_dummy_json(128, [1, 700], [1, 700])
      if swap_io:
          batchset = make_batchset(
              dummy_json,
              16,
              2**10,
              2**10,
              batch_sort_key="input",
              shortest_first=True,
              swap_io=True,
          )
          key = "output"
      else:
          batchset = make_batchset(
              dummy_json, 16, 2**10, 2**10, shortest_first=True
          )
          key = "input"
      prev_start_ilen = batchset[0][0][1][key][0]["shape"][0]
      for batch in batchset:
          cur_start_ilen = batch[0][1][key][0]["shape"][0]
          assert cur_start_ilen >= prev_start_ilen
          prev_ilen = cur_start_ilen
          for sample in batch:
              cur_ilen = sample[1][key][0]["shape"][0]
              assert cur_ilen <= prev_ilen
              prev_ilen = cur_ilen
          prev_start_ilen = cur_start_ilen
  
file_path: espnet/test/test_utils.py
imports: from test.utils_test import make_dummy_json
  import h5py
  import kaldiio
  import numpy
  import pytest
  from espnet.utils.io_utils import LoadInputsAndTargets, SoundHDF5File
  from espnet.utils.training.batchfy import make_batchset
label_desc: Use image node_id 2 for calling a global function with example usage: test_sortagrad(swap_io) without return types