code: def _GeneratorFromPath(path):
    
    if not path:
      raise ValueError('path must be a valid string')
    if io_wrapper.IsTensorFlowEventsFile(path):
      return event_file_loader.EventFileLoader(path)
    else:
      return directory_watcher.DirectoryWatcher(
          path,
          event_file_loader.EventFileLoader,
          io_wrapper.IsTensorFlowEventsFile)
docs: Create an event generator for file or directory at given path string.