class_docstr: Implementation of a ClusterResolver which reads the TF_CONFIG EnvVar.
  
  This is an implementation of cluster resolvers when using TF_CONFIG to set
  information about the cluster. The cluster spec returned will be
  initialized from the TF_CONFIG environment variable.
  
  An example to set TF_CONFIG is:
  
    ```Python
    os.environ['TF_CONFIG'] = json.dumps({
      'cluster': {
          'worker': ["localhost:12345", "localhost:23456"]
      },
      'task': {'type': 'worker', 'index': 0}
    })
    ```
  
  However, sometimes the container orchestration framework will set TF_CONFIG
  for you. In this case, you can just create an instance without passing in any
  arguments. You can find an example here to let Kuburnetes set TF_CONFIG for
  you: https://github.com/tensorflow/ecosystem/tree/master/kubernetes. Then you
  can use it with `tf.distribute.Strategy` as:
  
    ```Python
    # `TFConfigClusterResolver` is already the default one in the following
    # strategy.
    strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy(
        cluster_resolver=TFConfigClusterResolver())
    ```
class_docstr_tok: ["Implementation","of","a","ClusterResolver","which","reads","the","TF_CONFIG","EnvVar",".","This","is","an","implementation","of","cluster","resolvers","when","using","TF_CONFIG","to","set","information","about","the","cluster",".","The","cluster","spec","returned","will","be","initialized","from","the","TF_CONFIG","environment","variable",".","An","example","to","set","TF_CONFIG","is",":","``","`","Python","os.environ","[","'TF_CONFIG","'","]","=","json.dumps","(","{","'cluster","'",":","{","'worker","'",":","[","``","localhost:12345","''",",","``","localhost:23456","''","]","}",",","'task","'",":","{","'type","'",":","'worker","'",",","'index","'",":","0","}","}",")","``","`","However",",","sometimes","the","container","orchestration","framework","will","set","TF_CONFIG","for","you",".","In","this","case",",","you","can","just","create","an","instance","without","passing","in","any","arguments",".","You","can","find","an","example","here","to","let","Kuburnetes","set","TF_CONFIG","for","you",":","https",":","\/\/github.com\/tensorflow\/ecosystem\/tree\/master\/kubernetes",".","Then","you","can","use","it","with","`","tf.distribute.Strategy","`","as",":","``","`","Python","#","`","TFConfigClusterResolver","`","is","already","the","default","one","in","the","following","#","strategy",".","strategy","=","tf.distribute.experimental.MultiWorkerMirroredStrategy","(","cluster_resolver=TFConfigClusterResolver","(",")",")","``","`"]
docstr: Returns the master address to use when creating a TensorFlow session.
  
  Note: this is only useful for TensorFlow 1.x.
  
  Args:
    task_type: (String, optional) Overrides and sets the task_type of the
      master.
    task_id: (Integer, optional) Overrides and sets the task id of the
      master.
    rpc_layer: (String, optional) Overrides and sets the protocol over which
      TensorFlow nodes communicate with each other.
  
  Returns:
    The address of the master.
  
  Raises:
    RuntimeError: If the task_type or task_id is not specified and the
      `TF_CONFIG` environment variable does not contain a task section.
docstr_tok: ["Returns","the","master","address","to","use","when","creating","a","TensorFlow","session",".","Note",":","this","is","only","useful","for","TensorFlow","1.x",".","Args",":","task_type",":","(","String",",","optional",")","Overrides","and","sets","the","task_type","of","the","master",".","task_id",":","(","Integer",",","optional",")","Overrides","and","sets","the","task","id","of","the","master",".","rpc_layer",":","(","String",",","optional",")","Overrides","and","sets","the","protocol","over","which","TensorFlow","nodes","communicate","with","each","other",".","Returns",":","The","address","of","the","master",".","Raises",":","RuntimeError",":","If","the","task_type","or","task_id","is","not","specified","and","the","`","TF_CONFIG","`","environment","variable","does","not","contain","a","task","section","."]
code: def master(self, task_type=None, task_id=None, rpc_layer=None):
      """Returns the master address to use when creating a TensorFlow session.
  
      Note: this is only useful for TensorFlow 1.x.
  
      Args:
        task_type: (String, optional) Overrides and sets the task_type of the
          master.
        task_id: (Integer, optional) Overrides and sets the task id of the
          master.
        rpc_layer: (String, optional) Overrides and sets the protocol over which
          TensorFlow nodes communicate with each other.
  
      Returns:
        The address of the master.
  
      Raises:
        RuntimeError: If the task_type or task_id is not specified and the
          `TF_CONFIG` environment variable does not contain a task section.
      """
  
      # If `session_master` is set, just use that.
      session_master = _get_value_in_tfconfig(_SESSION_MASTER_KEY)
      if session_master is not None:
          return session_master
  
      # Return an empty string if we are the only job in the ClusterSpec.
      cluster_spec = self.cluster_spec()
      if not cluster_spec.jobs or (
          len(cluster_spec.jobs) == 1
          and len(cluster_spec.job_tasks(cluster_spec.jobs[0])) == 1
      ):
          return ""
  
      # We try to auto-detect the task type and id, but uses the user-supplied one
      # where available
      task_type = task_type if task_type is not None else self.task_type
      task_id = task_id if task_id is not None else self.task_id
      rpc_layer = rpc_layer if rpc_layer is not None else self.rpc_layer
  
      return format_master_url(
          cluster_spec.task_address(task_type, task_id), rpc_layer
      )
  
imports: import json
  import os
  from tensorflow.python.distribute.cluster_resolver.cluster_resolver import ClusterResolver
  from tensorflow.python.training.server_lib import ClusterSpec
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 11 for calling the TFConfigClusterResolver obj's underlying member method code with example usage: obj.master(task_type, task_id, rpc_layer) and returns: format_master_url, session_master, str