code: def nsamples_from_data(data):
      err_msg = "could not determine number of samples from %s" % (
          type(data)
      )
      if is_iter(data):
          if is_ktrain_dataset(data):
              return data.nsamples()
          elif hasattr(
              data, "samples"
          ):  # DirectoryIterator/DataFrameIterator
              return data.samples
          elif hasattr(
              data, "n"
          ):  # DirectoryIterator/DataFrameIterator/NumpyIterator
              return data.n
          else:
              raise Exception(err_msg)
      else:
          try:
              if type(data[0]) == list:  # BERT-style tuple
                  return len(data[0][0])
              else:
                  return len(data[0])  # standard tuple
          except:
              raise Exception(err_msg)
  
imports: from .imports import *
  from subprocess import Popen
label_desc: Use image node_id 20 for calling a global function with example usage: nsamples_from_data(data) and returns: data, data, len, len, data