code: def master_job(master, cluster_def):
      """Returns the canonical job name to use to place TPU computations on.
  
      Args:
        master: A `string` representing the TensorFlow master to use.
        cluster_def: A ClusterDef object describing the TPU cluster.
  
      Returns:
        A string containing the job name, or None if no job should be specified.
  
      Raises:
        ValueError: If the user needs to specify a tpu_job_name, because we are
          unable to infer the job name automatically, or if the user-specified job
          names are inappropriate.
      """
      # If the user specifies the tpu_job_name, use that.
  
      if master in _LOCAL_MASTERS:
          return None
  
      if not cluster_def or not cluster_def.job:
          return _DEFAULT_JOB_NAME
      job_names = set(job.name for job in cluster_def.job)
      if _DEFAULT_JOB_NAME in job_names:
          # b/37868888 tracks allowing ClusterSpec propagation to reuse job names.
          raise ValueError(
              "Currently, tpu_worker is not an allowed job name."
          )
      if len(job_names) == 1:
          return cluster_def.job[0].name
      if len(job_names) == 2:
          if _DEFAULT_COORDINATOR_JOB_NAME in job_names:
              job_names.remove(_DEFAULT_COORDINATOR_JOB_NAME)
              return job_names.pop()
          # TODO(b/67716447): Include more sophisticated heuristics.
      raise ValueError("Could not infer TPU job name.")
  
file_path: tensorflow/tensorflow/python/tpu/tpu_system_metadata.py
imports: import collections
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.distribute import device_util
  from tensorflow.python.eager import context
  from tensorflow.python.framework import config
  from tensorflow.python.framework import device
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.tpu import tpu
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 4 for calling a global function with example usage: master_job(master, cluster_def) and returns: None, _DEFAULT_JOB_NAME, cluster_def, job_names