code: def create_run_config(
      model_name,
      master="",
      model_dir=None,
      iterations_per_loop=1000,
      num_shards=8,
      log_device_placement=False,
      save_checkpoints_steps=1000,
      save_checkpoints_secs=None,
      keep_checkpoint_max=20,
      keep_checkpoint_every_n_hours=10000,
      num_gpus=1,
      gpu_order="",
      num_async_replicas=1,
      enable_graph_rewriter=False,
      gpu_mem_fraction=0.95,
      no_data_parallelism=False,
      optionally_use_dist_strat=False,
      daisy_chain_variables=True,
      schedule="continuous_train_and_eval",
      worker_job="/job:localhost",
      worker_id=0,
      ps_replicas=0,
      ps_job="/job:ps",
      ps_gpu=0,
      random_seed=None,
      sync=False,
      tpu_infeed_sleep_secs=None,
      use_tpu=False,
      use_tpu_estimator=False,
      xla_jit_level=tf.OptimizerOptions.OFF,
      inter_op_parallelism_threads=0,
      log_step_count_steps=100,
      intra_op_parallelism_threads=0,
      tpu_config_extra_kwargs=None,
      cloud_tpu_name="",
      cloud_tpu_zone=None,
  ):
      """Create RunConfig, TPUConfig, and Parallelism object."""
      session_config = create_session_config(
          log_device_placement=log_device_placement,
          enable_graph_rewriter=enable_graph_rewriter,
          gpu_mem_fraction=gpu_mem_fraction,
          use_tpu=use_tpu,
          xla_jit_level=xla_jit_level,
          inter_op_parallelism_threads=inter_op_parallelism_threads,
          intra_op_parallelism_threads=intra_op_parallelism_threads,
      )
      run_config_args = {
          "master": master,
          "evaluation_master": master,
          "model_dir": model_dir,
          "session_config": session_config,
          "save_summary_steps": 100,
          "save_checkpoints_steps": save_checkpoints_steps,
          "save_checkpoints_secs": save_checkpoints_secs,
          "keep_checkpoint_max": keep_checkpoint_max,
          "keep_checkpoint_every_n_hours": keep_checkpoint_every_n_hours,
          "tf_random_seed": random_seed,
          "log_step_count_steps": log_step_count_steps,
      }
      if save_checkpoints_secs:
          del run_config_args["save_checkpoints_steps"]
      run_config_cls = contrib.learn().RunConfig
  
      if use_tpu or use_tpu_estimator:
          # If using TPUEstimator, use TPU RunConfig, add TPUConfig, and add
          # additional args.
          tpu_config_kwargs = {
              "iterations_per_loop": iterations_per_loop,
              "num_shards": num_shards,
              "per_host_input_for_training": True,
              "initial_infeed_sleep_secs": tpu_infeed_sleep_secs,
          }
          if tpu_config_extra_kwargs is not None:
              tpu_config_kwargs.update(tpu_config_extra_kwargs)
          run_config_cls = contrib.tpu().RunConfig
          tpu_config = contrib.tpu().TPUConfig(**tpu_config_kwargs)
          run_config_args["tpu_config"] = tpu_config
          if (
              not master
              and "KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS" in os.environ
          ):
              # If running on TPU but no master is set and the KUBE env var is present
              # then we're running on ML Engine. Set the master.
              run_config_args["master"] = os.environ[
                  "KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS"
              ]
              run_config_args["evaluation_master"] = run_config_args[
                  "master"
              ]
          elif not master and cloud_tpu_name:
              # Update run_config to use cluster instead of master/evaluation_master
              # as we need the cluster spec to use Cloud Pods
              tpu_cluster_resolver = (
                  contrib.cluster_resolver().TPUClusterResolver(
                      tpu=cloud_tpu_name, zone=cloud_tpu_zone
                  )
              )
              run_config_args["cluster"] = tpu_cluster_resolver
              del run_config_args["master"]
              del run_config_args["evaluation_master"]
      elif is_cloud_async_distributed():
          run_config_cls = tf_estimator.RunConfig
          del run_config_args["master"]
          del run_config_args["evaluation_master"]
  
      # tf.estimator RunConfig construction got totally broken in TF2.
      # we now have to specify master in a global environment variable
      if contrib.is_tf2:
          del run_config_args["evaluation_master"]
          del run_config_args["master"]
  
      config = run_config_cls(**run_config_args)
  
      # If not using TPU, add device info for data_parallelism
      config.use_tpu = use_tpu
      if not use_tpu:
          config.t2t_device_info = {
              "num_async_replicas": num_async_replicas,
          }
          use_distribution_strategy = (
              optionally_use_dist_strat
              and t2t_model.T2TModel.has_symmetric_shards(model_name)
              and not no_data_parallelism
              and ps_replicas == 0
              and ps_gpu == 0
              and num_async_replicas == 1
          )
  
          if use_distribution_strategy:
              tf.logging.info(
                  "Configuring MirroredStrategy DistributionStrategy to replicate the "
                  "model."
              )
              distribution = contrib.distribute().MirroredStrategy()
              config = config.replace(train_distribute=distribution)
              config.data_parallelism = None
          else:
              tf.logging.info(
                  "Configuring DataParallelism to replicate the model."
              )
              config.data_parallelism = devices.data_parallelism(
                  daisy_chain_variables=daisy_chain_variables,
                  ps_replicas=ps_replicas,
                  ps_job=ps_job,
                  ps_gpu=ps_gpu,
                  schedule=schedule,
                  sync=sync,
                  worker_gpu=num_gpus,
                  worker_replicas=num_async_replicas,
                  worker_id=worker_id,
                  gpu_order=gpu_order,
                  worker_job=worker_job,
                  no_data_parallelism=no_data_parallelism,
              )
  
      return config
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import contextlib
  import json
  import os
  import random
  import numpy
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import decoding
  from tensor2tensor.utils import devices
  from tensor2tensor.utils import hparams_lib
  from tensor2tensor.utils import metrics_hook
  from tensor2tensor.utils import mlperf_log
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.core.protobuf import rewriter_config_pb2
  from tensorflow.python import debug
label_desc: Use image node_id 5 for calling a global function with example usage: create_run_config(model_name, master, model_dir, iterations_per_loop, num_shards, log_device_placement, save_checkpoints_steps, save_checkpoints_secs, keep_checkpoint_max, keep_checkpoint_every_n_hours, num_gpus, gpu_order, num_async_replicas, enable_graph_rewriter, gpu_mem_fraction, no_data_parallelism, optionally_use_dist_strat, daisy_chain_variables, schedule, worker_job, worker_id, ps_replicas, ps_job, ps_gpu, random_seed, sync, tpu_infeed_sleep_secs, use_tpu, use_tpu_estimator, xla_jit_level, inter_op_parallelism_threads, log_step_count_steps, intra_op_parallelism_threads, tpu_config_extra_kwargs, cloud_tpu_name, cloud_tpu_zone) and returns: config