code: def create_closure_callback_img_reader(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_reader(sample_info):
          if sample_info.idx_in_epoch >= data_set_size:
              raise StopIteration
          sample_idx = sample_info.idx_in_epoch % len(files)
          jpeg_filename = files[sample_idx]
          label = np.int32([labels[sample_idx]])
          with open(os.path.join(images_dir, jpeg_filename), "rb") as f:
              encoded_img = np.frombuffer(f.read(), dtype=np.uint8)
          return encoded_img, label
  
      return py_file_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 13 for calling a global function with example usage: create_closure_callback_img_reader(data_set_size) and returns: py_file_reader, encoded_img,  label