code: def test_sliced_data_iterator_equivalence(
      test_data_csv_png_10,
      num_of_slices,
      size,
      batch_size,
      shuffle,
      drop_last,
  ):
      def lcm(a, b):
          return abs(a * b) / math.gcd(a, b) if a and b else 0
  
      max_epoch = lcm(batch_size, size) / size
  
      def test_load_func(position):
          return np.full((1), position, dtype=np.int32)
  
      def simple_load_func(data_set, position):
          return data_set[position]
  
      def get_data(iter_list, iter_num):
          total = 0
          for it in iter_list:
              for _ in range(iter_num):
                  yield it.next()
                  total += 1
              yield total
          yield total
  
      iter_num = int(
          (max_epoch * size) / (num_of_slices * batch_size) + 0.5
      )
  
      sliced_di_list = []
      di = data_iterator_simple(
          test_load_func, size, batch_size, shuffle=shuffle
      )
  
      for slice_pos in range(num_of_slices):
          sliced_di = di.slice(
              rng=None,
              num_of_slices=num_of_slices,
              slice_pos=slice_pos,
              drop_last=drop_last,
          )
          sliced_di_list.append(sliced_di)
  
      ref_di_list = []
      all_data = [
          np.full((1), position, dtype=np.int32)
          for position in range(size)
      ]
      slice_block_size = size // num_of_slices
      if not drop_last:
          slice_block_size += 1 if size % num_of_slices != 0 else 0
      for slice_pos in range(num_of_slices):
          start_index = slice_pos * slice_block_size
          end_index = start_index + slice_block_size
          if end_index > size:
              end_index = size
              start_index = end_index - slice_block_size
          sliced_data = all_data[start_index:end_index]
          di = data_iterator_simple(
              partial(simple_load_func, sliced_data),
              slice_block_size,
              batch_size,
              shuffle=shuffle,
          )
          ref_di_list.append(di)
  
      set_a = set()
      set_b = set()
      for ref, t in zip(
          get_data(ref_di_list, iter_num),
          get_data(sliced_di_list, iter_num),
      ):
          if isinstance(ref, tuple):
              ref, t = ref[0], t[0]
          if isinstance(ref, np.ndarray):
              # print(f"{ref} <--> {t}")
              set_a = set_a.union(set(ref))
              set_b = set_b.union(set(t))
          else:
              # print("-" * 30)
              assert ref == t
      # str_a = ','.join([str(f) for f in set_a])
      # str_b = ','.join([str(f) for f in set_b])
      # print(f"{str_a}  <--> {str_b}")
      assert set_a == set_b
  
      di_all = ref_di_list + sliced_di_list
      for di in di_all:
          di.close()
  
file_path: nnabla/python/test/utils/test_sliced_data_iterator.py
imports: import pytest
  import numpy
  import math
  from functools import partial
  from nnabla.utils.data_source_loader import load_image
  from nnabla.utils.data_iterator import data_iterator_simple
  from .test_data_iterator import check_data_iterator_result
  from .conftest import generate_cache_dir
label_desc: Use image node_id 1 for calling a global function with example usage: test_sliced_data_iterator_equivalence(test_data_csv_png_10, num_of_slices, size, batch_size, shuffle, drop_last) and returns: unknown, np, data_set