parameters: (cluster_spec, task_type, task_id)
return_statement: return ''
docstring: Returns the appropriate string for the TensorFlow master.
docstring_summary: Returns the appropriate string for the TensorFlow master.
docstring_tokens: Returns the appropriate string for the TensorFlow master .
function: def _get_master(cluster_spec, task_type, task_id):
    """Returns the appropriate string for the TensorFlow master."""
    if not cluster_spec:
      return ''
  
    # If there is only one node in the cluster, do things locally.
    jobs = cluster_spec.jobs
    if len(jobs) == 1 and len(cluster_spec.job_tasks(jobs[0])) == 1:
      return ''
  
    # Lookup the master in cluster_spec using task_type and task_id,
    # if possible.
    if task_type:
      if task_type not in jobs:
        raise ValueError(
            '%s is not a valid task_type in the cluster_spec:\n'
            '%s\n\n'
            'Note that these values may be coming from the TF_CONFIG environment '
            'variable.' % (task_type, cluster_spec))
      addresses = cluster_spec.job_tasks(task_type)
      if task_id >= len(addresses) or task_id < 0:
        raise ValueError(
            '%d is not a valid task_id for task_type %s in the '
            'cluster_spec:\n'
            '%s\n\n'
            'Note that these value may be coming from the TF_CONFIG environment '
            'variable.' % (task_id, task_type, cluster_spec))
      return 'grpc://' + addresses[task_id]
  
    # For backwards compatibility, we return empty string if task_type was
    # not set (task_type did not previously exist).
    return ''
function_tokens: def _get_master ( cluster_spec , task_type , task_id ) : if not cluster_spec : return '' # If there is only one node in the cluster, do things locally. jobs = cluster_spec . jobs if len ( jobs ) == 1 and len ( cluster_spec . job_tasks ( jobs [ 0 ] ) ) == 1 : return '' # Lookup the master in cluster_spec using task_type and task_id, # if possible. if task_type : if task_type not in jobs : raise ValueError ( '%s is not a valid task_type in the cluster_spec:\n' '%s\n\n' 'Note that these values may be coming from the TF_CONFIG environment ' 'variable.' % ( task_type , cluster_spec ) ) addresses = cluster_spec . job_tasks ( task_type ) if task_id >= len ( addresses ) or task_id < 0 : raise ValueError ( '%d is not a valid task_id for task_type %s in the ' 'cluster_spec:\n' '%s\n\n' 'Note that these value may be coming from the TF_CONFIG environment ' 'variable.' % ( task_id , task_type , cluster_spec ) ) return 'grpc://' + addresses [ task_id ] # For backwards compatibility, we return empty string if task_type was # not set (task_type did not previously exist). return ''