code: def parse_events_files(tb_summary_dir, seqio_summaries=False):
      """Parse all TensorBoard events files in tb_summary_dir.
  
      Args:
        tb_summary_dir: str, path to look for events files in.
        seqio_summaries: boolean, whether event summaries are generated by SeqIO
          Evaluator.
  
      Returns:
        A dict, where each key is a TensorBoard tag and each value is a list of
        Event tuples with step and value attributes.
      """
      events = collections.defaultdict(list)
      for events_file in tf.io.gfile.glob(
          os.path.join(tb_summary_dir, "events.*")
      ):
          try:
              serialized_events = list(
                  tfds.as_numpy(tf.data.TFRecordDataset(events_file))
              )[1:]
              for idx, e in enumerate(
                  tf.train.summary_iterator(events_file)
              ):
                  for v in e.summary.value:
                      if seqio_summaries:
                          event = tf.compat.v1.Event.FromString(
                              serialized_events[idx - 1]
                          ).summary.value[0]
                          # Need to check if event has a tensor or scalar since we need to
                          # handle both cases.
                          if event.HasField("tensor"):
                              metric_value = tf.make_ndarray(
                                  event.tensor
                              )
                          else:
                              metric_value = event.simple_value
                      else:
                          metric_value = v.simple_value
                      events[v.tag].append(Event(e.step, metric_value))
          except tf.errors.DataLossError:
              logging.info(
                  "Skipping %s due to truncated record.", events_file
              )
      return events
  
file_path: text-to-text-transfer-transformer/t5/evaluation/eval_utils.py
imports: import collections
  import os
  from absl import logging
  import numpy
  import pandas
  import tensorflow.compat.v1
  import tensorflow_datasets
label_desc: Use image node_id 1 for calling a global function with example usage: parse_events_files(tb_summary_dir, seqio_summaries) and returns: events