parameters: (self, master=None, evaluation_master=None)
docstring: Constructor.
  
      Sets the properties `cluster_spec`, `is_chief`, `master` (if `None` in the
      args), `num_ps_replicas`, `task_id`, and `task_type` based on the
      `TF_CONFIG` environment variable, if the pertinent information is
      present. The `TF_CONFIG` environment variable is a JSON object with
      attributes: `cluster`, `environment`, and `task`.
  
      `cluster` is a JSON serialized version of `ClusterSpec`'s Python dict from
      `server_lib.py`, mapping task types (usually one of the TaskType enums) to a
      list of task addresses.
  
      `environment` specifies the runtime environment for the job (usually one of
      the `Environment` enums). Defaults to `LOCAL`.
  
      `task` has two attributes: `type` and `index`, where `type` can be any of
      the task types in `cluster`. When `TF_CONFIG` contains said information, the
      following properties are set on this class:
  
      * `task_type` is set to `TF_CONFIG['task']['type']`. Defaults to `None`.
      * `task_id` is set to `TF_CONFIG['task']['index']`. Defaults to 0.
      * `cluster_spec` is parsed from `TF_CONFIG['cluster']`. Defaults to {}.
      * `master` is determined by looking up `task_type` and `task_id` in the
        `cluster_spec`. Defaults to ''.
      * `num_ps_replicas` is set by counting the number of nodes listed
        in the `ps` attribute of `cluster_spec`. Defaults to 0.
      * `num_worker_replicas` is set by counting the number of nodes listed
        in the `worker` attribute of `cluster_spec`. Defaults to 0.
      * `is_chief` is deteremined based on `task_type`, `type_id`, and
        `environment`.
  
      Example:
      ```
        cluster = {'ps': ['host1:2222', 'host2:2222'],
                   'worker': ['host3:2222', 'host4:2222', 'host5:2222']}
        os.environ['TF_CONFIG'] = json.dumps(
            {'cluster': cluster,
             'task': {'type': 'worker', 'index': 1}})
        config = ClusterConfig()
        assert config.master == 'host4:2222'
        assert config.task_id == 1
        assert config.num_ps_replicas == 2
        assert config.num_worker_replicas == 3
        assert config.cluster_spec == server_lib.ClusterSpec(cluster)
        assert config.task_type == 'worker'
        assert not config.is_chief
      ```
  
      Args:
        master: TensorFlow master. Defaults to empty string for local.
        evaluation_master: The master on which to perform evaluation.
docstring_summary: Constructor.
docstring_tokens: Constructor .
function: def __init__(self, master=None, evaluation_master=None):
      """Constructor.
  
      Sets the properties `cluster_spec`, `is_chief`, `master` (if `None` in the
      args), `num_ps_replicas`, `task_id`, and `task_type` based on the
      `TF_CONFIG` environment variable, if the pertinent information is
      present. The `TF_CONFIG` environment variable is a JSON object with
      attributes: `cluster`, `environment`, and `task`.
  
      `cluster` is a JSON serialized version of `ClusterSpec`'s Python dict from
      `server_lib.py`, mapping task types (usually one of the TaskType enums) to a
      list of task addresses.
  
      `environment` specifies the runtime environment for the job (usually one of
      the `Environment` enums). Defaults to `LOCAL`.
  
      `task` has two attributes: `type` and `index`, where `type` can be any of
      the task types in `cluster`. When `TF_CONFIG` contains said information, the
      following properties are set on this class:
  
      * `task_type` is set to `TF_CONFIG['task']['type']`. Defaults to `None`.
      * `task_id` is set to `TF_CONFIG['task']['index']`. Defaults to 0.
      * `cluster_spec` is parsed from `TF_CONFIG['cluster']`. Defaults to {}.
      * `master` is determined by looking up `task_type` and `task_id` in the
        `cluster_spec`. Defaults to ''.
      * `num_ps_replicas` is set by counting the number of nodes listed
        in the `ps` attribute of `cluster_spec`. Defaults to 0.
      * `num_worker_replicas` is set by counting the number of nodes listed
        in the `worker` attribute of `cluster_spec`. Defaults to 0.
      * `is_chief` is deteremined based on `task_type`, `type_id`, and
        `environment`.
  
      Example:
      ```
        cluster = {'ps': ['host1:2222', 'host2:2222'],
                   'worker': ['host3:2222', 'host4:2222', 'host5:2222']}
        os.environ['TF_CONFIG'] = json.dumps(
            {'cluster': cluster,
             'task': {'type': 'worker', 'index': 1}})
        config = ClusterConfig()
        assert config.master == 'host4:2222'
        assert config.task_id == 1
        assert config.num_ps_replicas == 2
        assert config.num_worker_replicas == 3
        assert config.cluster_spec == server_lib.ClusterSpec(cluster)
        assert config.task_type == 'worker'
        assert not config.is_chief
      ```
  
      Args:
        master: TensorFlow master. Defaults to empty string for local.
        evaluation_master: The master on which to perform evaluation.
      """
      # If not explicitly specified in the constructor and the TF_CONFIG
      # environment variable is present, load cluster_spec from TF_CONFIG.
      config = json.loads(os.environ.get('TF_CONFIG') or '{}')
  
      # Set task_type and task_id if the TF_CONFIG environment variable is
      # present.  Otherwise, use the respective default (None / 0).
      task_env = config.get('task', {})
      self._task_type = task_env.get('type', None)
      self._task_id = self.get_task_id()
  
      self._cluster_spec = server_lib.ClusterSpec(config.get('cluster', {}))
      self._master = (master if master is not None else
                      _get_master(self._cluster_spec, self._task_type,
                                  self._task_id) or '')
      self._num_ps_replicas = _count_ps(self._cluster_spec) or 0
      self._num_worker_replicas = _count_worker(self._cluster_spec) or 0
  
      # Set is_chief.
      self._environment = config.get('environment', Environment.LOCAL)
      self._is_chief = None
      if self._task_type is None:
        self._is_chief = (self._task_id == 0)
      elif self._environment == Environment.CLOUD:
        # When the TF_CONFIG environment variable is set, we can set the
        # default of is_chief to 0 when task_type is "master" and task_id is 0.
        self._is_chief = (self._task_type == TaskType.MASTER and
                          self._task_id == 0)
      else:
        # Legacy behavior is that is_chief is None if task_id == 0.
        self._is_chief = (self._task_type == TaskType.WORKER and
                          self._task_id == 0)
  
      self._evaluation_master = evaluation_master or ''
function_tokens: def __init__ ( self , master = None , evaluation_master = None ) : # If not explicitly specified in the constructor and the TF_CONFIG # environment variable is present, load cluster_spec from TF_CONFIG. config = json . loads ( os . environ . get ( 'TF_CONFIG' ) or '{}' ) # Set task_type and task_id if the TF_CONFIG environment variable is # present.  Otherwise, use the respective default (None / 0). task_env = config . get ( 'task' , { } ) self . _task_type = task_env . get ( 'type' , None ) self . _task_id = self . get_task_id ( ) self . _cluster_spec = server_lib . ClusterSpec ( config . get ( 'cluster' , { } ) ) self . _master = ( master if master is not None else _get_master ( self . _cluster_spec , self . _task_type , self . _task_id ) or '' ) self . _num_ps_replicas = _count_ps ( self . _cluster_spec ) or 0 self . _num_worker_replicas = _count_worker ( self . _cluster_spec ) or 0 # Set is_chief. self . _environment = config . get ( 'environment' , Environment . LOCAL ) self . _is_chief = None if self . _task_type is None : self . _is_chief = ( self . _task_id == 0 ) elif self . _environment == Environment . CLOUD : # When the TF_CONFIG environment variable is set, we can set the # default of is_chief to 0 when task_type is "master" and task_id is 0. self . _is_chief = ( self . _task_type == TaskType . MASTER and self . _task_id == 0 ) else : # Legacy behavior is that is_chief is None if task_id == 0. self . _is_chief = ( self . _task_type == TaskType . WORKER and self . _task_id == 0 ) self . _evaluation_master = evaluation_master or ''