class_docstr: Represents a cluster as a set of "tasks", organized into "jobs".
  
  A `tf.train.ClusterSpec` represents the set of processes that
  participate in a distributed TensorFlow computation. Every
  `tf.distribute.Server` is constructed in a particular cluster.
  
  To create a cluster with two jobs and five tasks, you specify the
  mapping from job names to lists of network addresses (typically
  hostname-port pairs).
  
  ```python
  cluster = tf.train.ClusterSpec({"worker": ["worker0.example.com:2222",
                                             "worker1.example.com:2222",
                                             "worker2.example.com:2222"],
                                  "ps": ["ps0.example.com:2222",
                                         "ps1.example.com:2222"]})
  ```
  
  Each job may also be specified as a sparse mapping from task indices
  to network addresses. This enables a server to be configured without
  needing to know the identity of (for example) all other worker
  tasks:
  
  ```python
  cluster = tf.train.ClusterSpec({"worker": {1: "worker1.example.com:2222"},
                                  "ps": ["ps0.example.com:2222",
                                         "ps1.example.com:2222"]})
  ```
class_docstr_tok: ["Represents","a","cluster","as","a","set","of","``","tasks","''",",","organized","into","``","jobs","''",".","A","`","tf.train.ClusterSpec","`","represents","the","set","of","processes","that","participate","in","a","distributed","TensorFlow","computation",".","Every","`","tf.distribute.Server","`","is","constructed","in","a","particular","cluster",".","To","create","a","cluster","with","two","jobs","and","five","tasks",",","you","specify","the","mapping","from","job","names","to","lists","of","network","addresses","(","typically","hostname-port","pairs",")",".","``","`","python","cluster","=","tf.train.ClusterSpec","(","{","``","worker","''",":","[","``","worker0.example.com:2222","''",",","``","worker1.example.com:2222","''",",","``","worker2.example.com:2222","''","]",",","``","ps","''",":","[","``","ps0.example.com:2222","''",",","``","ps1.example.com:2222","''","]","}",")","``","`","Each","job","may","also","be","specified","as","a","sparse","mapping","from","task","indices","to","network","addresses",".","This","enables","a","server","to","be","configured","without","needing","to","know","the","identity","of","(","for","example",")","all","other","worker","tasks",":","``","`","python","cluster","=","tf.train.ClusterSpec","(","{","``","worker","''",":","{","1",":","``","worker1.example.com:2222","''","}",",","``","ps","''",":","[","``","ps0.example.com:2222","''",",","``","ps1.example.com:2222","''","]","}",")","``","`"]
docstr: Creates a `ClusterSpec`.
  
  Args:
    cluster: A dictionary mapping one or more job names to (i) a list of
      network addresses, or (ii) a dictionary mapping integer task indices to
      network addresses; or a `tf.train.ClusterDef` protocol buffer.
  
  Raises:
    TypeError: If `cluster` is not a dictionary mapping strings to lists
      of strings, and not a `tf.train.ClusterDef` protobuf.
docstr_tok: ["Creates","a","`","ClusterSpec","`",".","Args",":","cluster",":","A","dictionary","mapping","one","or","more","job","names","to","(","i",")","a","list","of","network","addresses",",","or","(","ii",")","a","dictionary","mapping","integer","task","indices","to","network","addresses",";","or","a","`","tf.train.ClusterDef","`","protocol","buffer",".","Raises",":","TypeError",":","If","`","cluster","`","is","not","a","dictionary","mapping","strings","to","lists","of","strings",",","and","not","a","`","tf.train.ClusterDef","`","protobuf","."]
code: def __init__(self, cluster):
      """Creates a `ClusterSpec`.
  
      Args:
        cluster: A dictionary mapping one or more job names to (i) a list of
          network addresses, or (ii) a dictionary mapping integer task indices to
          network addresses; or a `tf.train.ClusterDef` protocol buffer.
  
      Raises:
        TypeError: If `cluster` is not a dictionary mapping strings to lists
          of strings, and not a `tf.train.ClusterDef` protobuf.
      """
      if isinstance(cluster, dict):
          self._cluster_spec = {}
          for job_name, tasks in cluster.items():
              if isinstance(tasks, (list, tuple)):
                  job_tasks = {i: task for i, task in enumerate(tasks)}
              elif isinstance(tasks, dict):
                  job_tasks = {
                      int(i): task for i, task in tasks.items()
                  }
              else:
                  raise TypeError(
                      "The tasks for job %r must be a list or a dictionary "
                      "from integers to strings." % job_name
                  )
              self._cluster_spec[job_name] = job_tasks
          self._make_cluster_def()
      elif isinstance(cluster, cluster_pb2.ClusterDef):
          self._cluster_def = cluster
          self._cluster_spec = {}
          for job_def in self._cluster_def.job:
              self._cluster_spec[job_def.name] = {
                  i: t for i, t in job_def.tasks.items()
              }
      elif isinstance(cluster, ClusterSpec):
          self._cluster_def = cluster_pb2.ClusterDef()
          self._cluster_def.MergeFrom(cluster.as_cluster_def())
          self._cluster_spec = {}
          for job_def in self._cluster_def.job:
              self._cluster_spec[job_def.name] = {
                  i: t for i, t in job_def.tasks.items()
              }
      else:
          raise TypeError(
              "`cluster` must be a dictionary mapping one or more "
              "job names to lists of network addresses, or a "
              "`ClusterDef` protocol buffer"
          )
  
imports: from tensorflow.core.protobuf import cluster_pb2
  from tensorflow.core.protobuf import device_filters_pb2
  from tensorflow.core.protobuf import tensorflow_server_pb2
  from tensorflow.python.client import pywrap_tf_session
  from tensorflow.python.framework import errors
  from tensorflow.python.util import compat
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 to create a new ClusterSpec object  with example: obj = ClusterSpec(cluster)