code: def read_tfevents_files(logdir):
      """Returns Event protos read from tfevents files in the directory.
  
      This does not recursively descend into subdirectories (like real
      TensorBoard); it reads only files that are at the top level.
  
      Args:
        logdir: string directory path to read
  
      Returns:
        A dict mapping filenames to lists of event_pb2.Event protos read
        from that file.
      """
      filenames = glob.glob(os.path.join(logdir, "*tfevents*"))
      results = {}
      for filename in sorted(filenames):
          events = []
          reader = pywrap_tensorflow.PyRecordReader_New(filename)
          while True:
              try:
                  reader.GetNext()
              except errors.OutOfRangeError:
                  break
              events.append(event_pb2.Event.FromString(reader.record()))
          results[filename] = events
      return results
  
imports: import glob
  import os
  from tensorboard.compat.proto import event_pb2
  from tensorboard.compat.tensorflow_stub import errors
  from tensorboard.compat.tensorflow_stub import pywrap_tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: read_tfevents_files(logdir) and returns: results