code: def nclasses_from_data(data):
      if is_iter(data):
          if is_ktrain_dataset(data):
              return data.nclasses()
          elif hasattr(data, "classes"):  # DirectoryIterator
              return len(set(data.classes))
          else:
              try:
                  return data[0][1].shape[
                      1
                  ]  # DataFrameIterator/NumpyIterator
              except:
                  raise Exception(
                      "could not determine number of classes from %s"
                      % (type(data))
                  )
      else:
          try:
              return data[1].shape[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 21 for calling a global function with example usage: nclasses_from_data(data) and returns: data, data, len, data