code: def build_image_dataset_from_dir(
      directory,
      dataset_file="my_tflearn_dataset.pkl",
      resize=None,
      convert_gray=None,
      filetypes=None,
      shuffle_data=False,
      categorical_Y=False,
  ):
      try:
          X, Y = pickle.load(open(dataset_file, "rb"))
      except Exception:
          X, Y = image_dirs_to_samples(
              directory, resize, convert_gray, filetypes
          )
          if categorical_Y:
              Y = to_categorical(Y, np.max(Y) + 1)  # First class is '0'
          if shuffle_data:
              X, Y = shuffle(X, Y)
          pickle.dump((X, Y), open(dataset_file, "wb"))
      return X, Y
  
imports: from __future__ import division, print_function, absolute_import
  import os
  import random
  import numpy
  from PIL import Image
  import pickle
  import csv
  import warnings
  import tensorflow.compat.v1
  from io import BytesIO
label_desc: Use image node_id 16 for calling a global function with example usage: build_image_dataset_from_dir(directory, dataset_file, resize, convert_gray, filetypes, shuffle_data, categorical_Y) and returns: X,  Y