code: def check_eventfile_for_keyword(keyword, dir_):
      """Checks event files for the keyword."""
  
      tf_compat.v1.summary.FileWriterCache.clear()
  
      if not tf.io.gfile.exists(dir_):
          raise ValueError("Directory '{}' not found.".format(dir_))
  
      # Get last `Event` written.
      filenames = os.path.join(dir_, "events*")
      event_paths = tf.io.gfile.glob(filenames)
      if not event_paths:
          raise ValueError("Path '{}' not found.".format(filenames))
  
      for event_path in event_paths:
          for last_event in tf_compat.v1.train.summary_iterator(
              event_path
          ):
              if last_event.summary is not None:
                  for value in last_event.summary.value:
                      if keyword == value.tag:
                          if value.HasField("simple_value"):
                              return value.simple_value
                          if value.HasField("image"):
                              return (
                                  value.image.height,
                                  value.image.width,
                                  value.image.colorspace,
                              )
                          if value.HasField("tensor"):
                              if (
                                  value.metadata.plugin_data.plugin_name
                                  == "scalars"
                              ):
                                  return summary_simple_value(value)
                              if (
                                  value.metadata.plugin_data.plugin_name
                                  == "images"
                              ):
                                  return (
                                      int(value.tensor.string_val[0]),
                                      int(value.tensor.string_val[1]),
                                      1,
                                  )
                              if value.tensor.string_val is not None:
                                  return value.tensor.string_val
  
      raise ValueError(
          "Keyword '{}' not found in path '{}'.".format(
              keyword, filenames
          )
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import shutil
  import struct
  import sys
  from absl import flags
  from absl.testing import parameterized
  from adanet import ensemble
  from adanet import subnetwork
  from adanet import tf_compat
  from adanet.core.architecture import _Architecture
  from adanet.core.candidate import _Candidate
  from adanet.core.ensemble_builder import _EnsembleSpec
  from adanet.core.ensemble_builder import _SubnetworkSpec
  from adanet.core.eval_metrics import _EnsembleMetrics
  from adanet.core.eval_metrics import _IterationMetrics
  from adanet.core.eval_metrics import _SubnetworkMetrics
  import tensorflow.compat.v2
label_desc: Use image node_id 9 for calling a global function with example usage: check_eventfile_for_keyword(keyword, dir_) and returns: value, value,  value,  value, summary_simple_value, int,  int,  int, value