code: def main(unused_argv):
      filename = FLAGS.phoenix_spec_filename
      spec = phoenix_spec_pb2.PhoenixSpec()
      with tf.io.gfile.GFile(filename, "r") as f:
          text_format.Merge(f.read(), spec)
  
      dataset_provider = get_dataset_provider()
      (
          loss_fn,
          metric_fn,
          predictions_fn,
      ) = loss_and_metric_and_predictions_fn(dataset_provider)
      metadata = None
      if (
          FLAGS.optimization_goal != "minimize"
          or FLAGS.optimization_metric != "loss"
      ):
          metadata = ml_metadata_db.MLMetaData(
              phoenix_spec=spec,
              study_name=FLAGS.experiment_name,
              study_owner=FLAGS.experiment_owner,
              optimization_goal=FLAGS.optimization_goal,
              optimization_metric=FLAGS.optimization_metric,
          )
      phoenix_instance = phoenix.Phoenix(
          phoenix_spec=spec,
          input_layer_fn=dataset_provider.get_input_layer_fn(
              spec.problem_type
          ),
          logits_dimension=dataset_provider.number_of_classes(),
          study_name=FLAGS.experiment_name,
          study_owner=FLAGS.experiment_owner,
          loss_fn=loss_fn,
          metric_fn=metric_fn,
          predictions_fn=predictions_fn,
          metadata=metadata,
      )
  
      # Replay only!!
      if spec.HasField("replay"):
          hparams = hp.HParams.from_proto(spec.replay.towers[0].hparams)
          run_train_and_eval(
              hparams,
              FLAGS.model_dir,
              phoenix_instance,
              dataset_provider,
              train_steps=FLAGS.phoenix_train_steps,
              eval_steps=FLAGS.phoenix_eval_steps,
              batch_size=FLAGS.phoenix_batch_size,
          )
          return 0
  
      tuner_id = FLAGS.tuner_id or "phoenix-tuner-%d" % random.randint(
          0, 10000000
      )
      hyperparameters = phoenix.Phoenix.get_keras_hyperparameters_space(
          spec, FLAGS.phoenix_train_steps
      )
  
      if FLAGS.hypertuning_method == "random":
          oracle = keras_tuner.oracles.RandomSearchOracle(
              objective="loss",
              max_trials=FLAGS.experiment_max_num_trials,
              seed=73,
              hyperparameters=hyperparameters,
              allow_new_entries=True,
              tune_new_entries=True,
          )
      else:
          oracle = keras_tuner.oracles.BayesianOptimizationOracle(
              objective="loss",
              hyperparameters=hyperparameters,
              max_trials=FLAGS.experiment_max_num_trials,
          )
  
      # pylint: disable=protected-access
      oracle._set_project_dir(
          FLAGS.model_dir, FLAGS.experiment_name, overwrite=True
      )
      # pylint: enable=protected-access
  
      data_provider = get_dataset_provider()
      if (
          getattr(data_provider, "get_keras_input", None) is not None
          and not FLAGS.force_estimator
      ):
          logging.info("Searching over TF keras models.")
          tf.config.run_functions_eagerly(True)
          run_keras_parameterized_train_and_eval(
              phoenix_instance=phoenix_instance,
              oracle=oracle,
              data_provider=data_provider,
          )
  
      else:
          logging.info("Searching over TF estimator models")
          while run_parameterized_train_and_eval(
              phoenix_instance=phoenix_instance,
              oracle=oracle,
              tuner_id=tuner_id,
              root_dir=FLAGS.model_dir,
              max_trials=FLAGS.experiment_max_num_trials,
              data_provider=data_provider,
              train_steps=FLAGS.phoenix_train_steps,
              eval_steps=FLAGS.phoenix_eval_steps,
              batch_size=FLAGS.phoenix_batch_size,
          ):
              pass
  
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 10 for calling a global function with example usage: main(unused_argv) and returns: int