code: def test_h5iterator(backend_default, hdf5datafile, onehot):
      NervanaObject.be.bsz = 128
      bsz = 128
  
      fn = hdf5datafile
      if onehot:
          datit = HDF5IteratorOneHot(fn)
      else:
          datit = HDF5Iterator(fn)
      cnt_image = 0
      cnt_target = 0
      max_len = datit.ndata
      mb_cnt = 0
      MAX_CNT = max_len * datit.inp.shape[1]
      for x, t in datit:
          x_ = x.get()
          t_ = t.get()
          assert x_.shape[1] == t_.shape[1]
          assert not np.all(x_ == 0)
          assert not np.all(t_ == 0)
  
          x_ = x_.T.flatten()
          x_exp = (np.arange(len(x_)) + cnt_image) % MAX_CNT
          assert np.all(x_ == x_exp)
          cnt_image += len(x_)
  
          if onehot:
              t_ = np.argmax(t_, axis=0).flatten()
          else:
              t_ = t_.flatten()
          t_exp = (np.arange(len(t_)) + cnt_target) % max_len
          assert np.all(t_ == t_exp)
          cnt_target += len(t_)
  
          mb_cnt += 1
      assert mb_cnt == int(math.ceil(datit.inp.shape[0] / float(bsz)))
      datit.cleanup()
  
file_path: neon/tests/test_hdf5iterator.py
imports: import os
  import math
  import h5py
  import pytest
  import logging
  import tempfile
  import numpy
  from neon import NervanaObject
  from neon.data import HDF5Iterator, HDF5IteratorOneHot, HDF5IteratorAutoencoder
  from utils import allclose_with_out
label_desc: Use image node_id 6 for calling a global function with example usage: test_h5iterator(backend_default, hdf5datafile, onehot) without return types