code: def y_from_data(data):
      if is_iter(data):
          if is_ktrain_dataset(data):
              return data.get_y()
          elif hasattr(data, "classes"):  # DirectoryIterator
              return keras.utils.to_categorical(data.classes)
          elif hasattr(data, "labels"):  # DataFrameIterator
              return data.labels
          elif hasattr(data, "y"):  # NumpyArrayIterator
              # return to_categorical(data.y)
              return data.y
          else:
              raise Exception(
                  "could not determine number of classes from %s"
                  % (type(data))
              )
      else:
          try:
              return data[1]
          except:
              raise Exception(
                  "could not determine number of classes from %s"
                  % (type(data))
              )
  
imports: from .imports import *
  from subprocess import Popen
label_desc: Use image node_id 22 for calling a global function with example usage: y_from_data(data) and returns: data, data, keras, data, data