code: def frompath(path, accessor=None, ext=None, start=None, stop=None, recursive=False, npartitions=None, dims=None, dtype=None, labels=None, recount=False, engine=None, credentials=None):
      
      from thunder.readers import get_parallel_reader
      reader = get_parallel_reader(path)(engine, credentials=credentials)
      data = reader.read(path, ext=ext, start=start, stop=stop,
                         recursive=recursive, npartitions=npartitions)
  
      if spark and isinstance(engine, spark):
          if accessor:
              data = data.flatMap(accessor)
          if recount:
              nrecords = None
  
              def switch(record):
                  ary, idx = record
                  return (idx,), ary
  
              data = data.values().zipWithIndex().map(switch)
          else:
              nrecords = reader.nfiles
          return fromrdd(data, nrecords=nrecords, dims=dims, dtype=dtype, labels=labels, ordered=True)
  
      else:
          if accessor:
              data = [accessor(d) for d in data]
          flattened = list(itertools.chain(*data))
          values = [kv[1] for kv in flattened]
          return fromarray(values, labels=labels)
docs: Load images from a path using the given accessor.
  
      Supports both local and remote filesystems.
  
      Parameters
      ----------
      accessor : function
          Apply to each item after loading to yield an image.
  
      ext : str, optional, default=None
          File extension.
  
      npartitions : int, optional, default=None
          Number of partitions for computational engine,
          if None will use default for engine.
  
      dims : tuple, optional, default=None
          Dimensions of images.
  
      dtype : str, optional, default=None
          Numerical type of images.
  
      labels : array, optional, default = None
          Labels for records. If provided, should be one-dimensional.
  
      start, stop : nonnegative int, optional, default=None
          Indices of files to load, interpreted using Python slicing conventions.
  
      recursive : boolean, optional, default=False
          If true, will recursively descend directories from path, loading all files
          with an extension matching 'ext'.
  
      recount : boolean, optional, default=False
          Force subsequent record counting.