code: def test_data_iterator_simple(
      test_data_csv_png_10, batch_size, shuffle, stop_exhausted
  ):
      src_data = []
      with open(test_data_csv_png_10) as f:
          for l in f.readlines():
              values = [x.strip() for x in l.split(",")]
              img_file_name = os.path.join(
                  os.path.dirname(test_data_csv_png_10), values[0]
              )
              if os.path.exists(img_file_name):
                  with open(img_file_name, "rb") as img_file:
                      d = load_image(img_file)
                      src_data.append((d, [int(values[1])]))
  
      def test_load_func(position):
          return src_data[position]
  
      def end_epoch(epoch):
          print(f"{epoch} == {expect_epoch[0]}")
          assert epoch == expect_epoch[0], "Failed for end epoch check"
          assert (
              threading.current_thread().ident == main_thread
          ), "Failed for thread checking"
  
      def begin_epoch(epoch):
          print(f"{epoch} == {expect_epoch[0]}")
          assert (
              epoch == expect_epoch[0]
          ), "Failed for begin epoch check"
          assert (
              threading.current_thread().ident == main_thread
          ), "Failed for thread checking"
  
      size = len(src_data)
      main_thread = threading.current_thread().ident
      expect_epoch = [0]
      with data_iterator_simple(
          test_load_func,
          size,
          batch_size,
          shuffle=shuffle,
          stop_exhausted=stop_exhausted,
      ) as di:
          if batch_size // size == 0:
              di.register_epoch_end_callback(begin_epoch)
              di.register_epoch_end_callback(end_epoch)
          di.register_epoch_end_callback(begin_epoch)
          di.register_epoch_end_callback(end_epoch)
          check_data_iterator_result(
              di,
              batch_size,
              shuffle,
              False,
              stop_exhausted,
              expect_epoch,
          )
  
imports: from __future__ import absolute_import
  import os
  import pytest
  import threading
  import numpy
  from nnabla.logger import logger
  from nnabla.config import nnabla_config
  from nnabla.utils.data_source_loader import load_image
  from nnabla.utils.data_iterator import data_iterator_csv_dataset
  from nnabla.utils.data_iterator import data_iterator_simple
  from nnabla.utils.data_iterator import data_iterator_concat_datasets
  from nnabla.utils.data_source_implements import CsvDataSource
  from .conftest import test_data_csv_png_10, test_data_csv_png_20
label_desc: Use image node_id 3 for calling a global function with example usage: test_data_iterator_simple(test_data_csv_png_10, batch_size, shuffle, stop_exhausted) and returns: src_data