code: def load_data(
      file, task_spec=None, batch_size=16, epochs=1, shuffle_size=0
  ):
      # load classes dict:
      with tf.gfile.Open(CLASSES_FILE) as f:
          labels = dict()
          for i, line in enumerate(f.readlines()):
              label = line.strip()
              labels[label] = i
      num_classes = len(labels)
      # count file examples
      with tf.gfile.Open(file) as f:
          size = len(f.readlines())
  
      image_size = inception_v3.default_image_size
      dataset = tf.data.TextLineDataset([file])
      dataset = dataset.repeat(epochs)
      # split the dataset in shards
      if (
          task_spec is not None
          and task_spec.num_workers > 1
          and not task_spec.is_evaluator()
      ):
          dataset = dataset.shard(
              num_shards=task_spec.num_workers,
              index=task_spec.shard_index,
          )
      if shuffle_size > 0:
          dataset = dataset.shuffle(buffer_size=shuffle_size)
  
      def _parse_example_fn(line):
          line_split = line.decode().split(",")
          filename = line_split[0]
          labels_names = line_split[1:]
          # labels
          one_hot_labels = np.zeros(num_classes, dtype=np.float32)
          for l in labels_names:
              one_hot_labels[labels[l]] = 1.0
          # image
          image_bytes = tf.gfile.FastGFile(filename, "rb").read()
          return image_bytes, one_hot_labels
  
      def _map_fn(example_serialized):
          image_bytes, one_hot_labels = tf.py_func(
              _parse_example_fn,
              [example_serialized],
              [tf.string, tf.float32],
              stateful=False,
          )
  
          image = tf.image.decode_jpeg(image_bytes, channels=3)
          image = tf.image.resize_images(
              image, size=[image_size, image_size]
          )
          image = tf.image.convert_image_dtype(image, dtype=tf.float32)
          one_hot_labels = tf.reshape(one_hot_labels, [num_classes])
          return image, one_hot_labels
  
      max_cpus = multiprocessing.cpu_count()
      dataset = dataset.map(_map_fn, num_parallel_calls=max_cpus)
      dataset = dataset.prefetch(batch_size * max_cpus + 100)
      dataset = dataset.batch(batch_size)
      (
          images,
          one_hot_classes,
      ) = dataset.make_one_shot_iterator().get_next()
  
      images = tf.reshape(
          images, [batch_size, image_size, image_size, 3]
      )
      one_hot_classes = tf.reshape(
          one_hot_classes, [batch_size, num_classes]
      )
  
      return images, one_hot_classes, num_classes, size
  
imports: import argparse
  import logging
  import multiprocessing
  import os
  import random
  import sys
  import time
  from xml.etree import ElementTree
  import numpy
  import tensorflow
  from tensorflow.contrib import slim
  from tensorflow.contrib.slim.python.slim.nets.inception_v3 import inception_v3, inception_v3_arg_scope
  from tensorflow.python.framework.errors_impl import OutOfRangeError
  from tensorflow.python.training import session_run_hook
  from tensorflow.python.training.basic_session_run_hooks import StopAtStepHook
  from tensorflow.python.training.monitored_session import SingularMonitoredSession
  import tensorlayer
label_desc: Use image node_id 5 for calling a global function with example usage: load_data(file, task_spec, batch_size, epochs, shuffle_size) and returns: images,  one_hot_classes,  num_classes,  size, image_bytes,  one_hot_labels, image,  one_hot_labels