code: def make_run_config(model_dir=None, use_tpu=False):
      """Makes a RunConfig object with FLAGS.
  
      Args:
        model_dir: string - the model directory - to be used in the tpu run config
          only.
        use_tpu: boolean indicating if to use tpu run config or not.
  
      Returns:
        tf.estimator.RunConfig: Run config.
  
      Raises:
        ValueError: If not exactly one of `save_checkpoints_secs` and
          `save_checkpoints_steps` is specified.
      """
      save_checkpoints_secs = (
          FLAGS.phoenix_save_checkpoints_secs or None
      )
      save_checkpoints_steps = (
          FLAGS.phoenix_save_checkpoints_steps or None
      )
      if save_checkpoints_secs and save_checkpoints_steps:
          raise ValueError(
              "save_checkpoints_secs and save_checkpoints_steps "
              "cannot both be non-zero."
          )
      if not (save_checkpoints_secs or save_checkpoints_steps):
          raise ValueError(
              "save_checkpoints_secs and save_checkpoints_steps "
              "cannot both be zero."
          )
  
      if use_tpu:
          return tf.compat.v1.estimator.tpu.RunConfig(
              tpu_config=tf.compat.v1.estimator.tpu.TPUConfig(
                  iterations_per_loop=200
              ),
              model_dir=model_dir,
              master=FLAGS.phoenix_master,
              save_summary_steps=FLAGS.phoenix_save_summary_steps,
              save_checkpoints_secs=save_checkpoints_secs,
              save_checkpoints_steps=save_checkpoints_steps,
              keep_checkpoint_max=FLAGS.phoenix_keep_checkpoint_max,
              tf_random_seed=None,
          )
  
      return tf.estimator.RunConfig(
          model_dir=model_dir,
          save_summary_steps=FLAGS.phoenix_save_summary_steps,
          save_checkpoints_secs=save_checkpoints_secs,
          save_checkpoints_steps=save_checkpoints_steps,
          keep_checkpoint_max=FLAGS.phoenix_keep_checkpoint_max,
          tf_random_seed=FLAGS.phoenix_tf_random_seed,
      )
  
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 4 for calling a global function with example usage: make_run_config(model_dir, use_tpu) and returns: tf, tf