code: def extract_event_log_values(
      event_file: str,
      event_tag: str,
      end_step: Optional[int] = None,
      start_step: Optional[int] = 0,
  ) -> Tuple[Dict[int, np.generic], float]:
      """Extracts the event values for the `event_tag` and total wall time.
  
      Args:
        event_file: Path to the event log.
        event_tag: Event to extract from the logs.
        end_step: If set, processing of the event log ends on this step.
        start_step: First step to look for in event log, defaults to 0.
  
      Returns:
        Tuple with a dict of int: np.generic (step: event value) and the total
          walltime in minutes.
  
      Raises:
        ValueError: If no events are found or the final step is smaller than the
          `end_step` requested.
      """
      current_step = 0
      start_time = 0
      max_wall_time = 0.0
      logging.info("Processing event file: %s", event_file)
      event_values = {}
      for summary in summary_iterator(event_file):
          current_step = summary.step
          logging.debug("Event log item: %s", summary)
          for value in summary.summary.value:
              if value.tag == event_tag:
                  ndarray = tf.make_ndarray(value.tensor)
                  if current_step >= start_step:
                      event_values[summary.step] = ndarray.item(0)
                      if current_step == start_step:
                          start_time = summary.wall_time
                          logging.info(
                              "training start (step %d): %s",
                              current_step,
                              datetime.datetime.fromtimestamp(
                                  summary.wall_time
                              ).strftime("%Y-%m-%d %H:%M:%S.%f"),
                          )
                  # Avoids issue of summaries not recorded in order.
                  max_wall_time = max(summary.wall_time, max_wall_time)
          if end_step and summary.step >= end_step:
              break
  
      if not start_time:
          raise ValueError(
              "Error: Starting event not found. Check arg event_name and "
              "warmup_steps. Possible no events were found."
          )
  
      if end_step and current_step < end_step:
          raise ValueError(
              "Error: Final step was less than the requested end_step."
          )
  
      elapse_time = (max_wall_time - start_time) / 60
      logging.info(
          "training end (step %d): %s",
          current_step,
          datetime.datetime.fromtimestamp(max_wall_time).strftime(
              "%Y-%m-%d %H:%M:%S.%f"
          ),
      )
      logging.info("elapsed time:%dm", elapse_time)
      return event_values, elapse_time
  
imports: import datetime
  import os
  import time
  from typing import Dict, Optional, Tuple
  from absl import logging
  import numpy
  from six.moves import range
  from six.moves import zip
  import tensorflow
  from tensorflow.core.util import event_pb2
  from tensorflow.python.lib.io import tf_record
label_desc: Use image node_id 8 for calling a global function with example usage: extract_event_log_values(event_file, event_tag, end_step, start_step) and returns: event_values,  elapse_time