code: def create_closure_generator_img_reader(batch_size, data_set_size):
      data_root = get_dali_extra_path()
      images_dir = os.path.join(data_root, "db", "single", "jpeg")
  
      with open(os.path.join(images_dir, "image_list.txt"), "r") as f:
          file_label = [
              line.rstrip().split(" ") for line in f if line != ""
          ]
          files, labels = zip(*file_label)
  
      def py_file_gen_reader():
          i = 0
          while i + batch_size <= data_set_size:
              batch_imgs, batch_labels = [], []
              for _ in range(batch_size):
                  jpeg_filename = files[i]
                  with open(
                      os.path.join(images_dir, jpeg_filename), "rb"
                  ) as f:
                      batch_imgs.append(
                          np.frombuffer(f.read(), dtype=np.uint8)
                      )
                  batch_labels.append(np.int32([labels[i]]))
                  i += 1
              yield batch_imgs, batch_labels
  
      return py_file_gen_reader
  
imports: import copyreg
  import numpy
  import nvidia.dali.fn
  import nvidia.dali.pickling
  import os
  from nvidia.dali import pipeline_def
  from pickle import PicklingError
  from nose_utils import raises
  from test_utils import get_dali_extra_path, restrict_python_version
label_desc: Use image node_id 14 for calling a global function with example usage: create_closure_generator_img_reader(batch_size, data_set_size) and returns: py_file_gen_reader