code: def run_train_and_eval(
      hparams,
      model_dir,
      phoenix_instance,
      data_provider,
      train_steps,
      eval_steps,
      batch_size,
  ):
      """Trains one trial."""
      run_config = make_run_config(
          model_dir=model_dir, use_tpu=FLAGS.phoenix_use_tpu
      )
  
      if FLAGS.phoenix_use_tpu:
          estimator = phoenix_instance.get_tpu_estimator(
              run_config=run_config,
              hparams=hparams,
              train_steps=train_steps,
              train_batch_size=batch_size,
              eval_on_tpu=FLAGS.phoenix_eval_on_tpu,
          )
      else:
          estimator = phoenix_instance.get_estimator(
              run_config=run_config,
              hparams=hparams,
              train_steps=train_steps,
          )
      estimator.train(
          input_fn=data_provider.get_input_fn(
              hparams=hparams,
              mode=tf.estimator.ModeKeys.TRAIN,
              batch_size=batch_size,
          ),
          max_steps=train_steps,
      )
      tf.compat.v1.reset_default_graph()
      tf.keras.backend.clear_session()
      tf.compat.v1.Session.reset(target=FLAGS.phoenix_master)
      assert eval_steps > 0
      eval_results = estimator.evaluate(
          input_fn=data_provider.get_input_fn(
              hparams=hparams,
              mode=tf.estimator.ModeKeys.EVAL,
              batch_size=batch_size,
          ),
          steps=eval_steps,
      )
  
      if FLAGS.phoenix_export_saved_model:
          tf.compat.v1.reset_default_graph()
          tf.keras.backend.clear_session()
          tf.compat.v1.Session.reset(target=FLAGS.phoenix_master)
          estimator.export_saved_model(
              os.path.join(model_dir, "saved_model"),
              data_provider.get_serving_input_fn(hparams=hparams),
          )
  
      tf.compat.v1.reset_default_graph()
      tf.keras.backend.clear_session()
      tf.compat.v1.Session.reset(target=FLAGS.phoenix_master)
      logging.info("Evaluation results: %s", eval_results)
      # Oracle save metrics as json which cannot handle numpy
      eval_results = {k: v.item() for k, v in eval_results.items()}
      return eval_results
  
imports: import contextlib
  import copy
  import json
  import os
  import random
  from absl import flags
  from absl import logging
  import keras_tuner
  from model_search import hparam
  from model_search import phoenix
  from model_search import registry
  from model_search.data import data
  from model_search.metadata import ml_metadata_db
  from model_search.proto import phoenix_spec_pb2
  import tensorflow.compat.v2
  from google.protobuf import text_format
label_desc: Use image node_id 5 for calling a global function with example usage: run_train_and_eval(hparams, model_dir, phoenix_instance, data_provider, train_steps, eval_steps, batch_size) and returns: eval_results