code: def test_data_iterator_slice(
      test_data_csv_png_10,
      batch_size,
      shuffle,
      stop_exhausted,
      comm_size,
      drop_last,
  ):
      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]
  
      size = len(src_data)
      di_list = []
      with data_iterator_simple(
          test_load_func,
          size,
          batch_size,
          shuffle=shuffle,
          stop_exhausted=stop_exhausted,
      ) as di:
          for comm_rank in range(comm_size):
              rng = np.random.RandomState(comm_rank * 19)
              di_list.append(
                  di.slice(
                      rng, comm_size, comm_rank, drop_last=drop_last
                  )
              )
          check_iterator_list(di_list)
  
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 7 for calling a global function with example usage: test_data_iterator_slice(test_data_csv_png_10, batch_size, shuffle, stop_exhausted, comm_size, drop_last) and returns: src_data