class_docstr: ClusterResolver for Google Compute Engine.
  
  This is an implementation of cluster resolvers for the Google Compute Engine
  instance group platform. By specifying a project, zone, and instance group,
  this will retrieve the IP address of all the instances within the instance
  group and return a ClusterResolver object suitable for use for distributed
  TensorFlow.
  
  Note: this cluster resolver cannot retrieve `task_type`, `task_id` or
  `rpc_layer`. To use it with some distribution strategies like
  `tf.distribute.experimental.MultiWorkerMirroredStrategy`, you will need to
  specify `task_type` and `task_id` in the constructor.
  
  Usage example with tf.distribute.Strategy:
  
    ```Python
    # On worker 0
    cluster_resolver = GCEClusterResolver("my-project", "us-west1",
                                          "my-instance-group",
                                          task_type="worker", task_id=0)
    strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy(
        cluster_resolver=cluster_resolver)
  
    # On worker 1
    cluster_resolver = GCEClusterResolver("my-project", "us-west1",
                                          "my-instance-group",
                                          task_type="worker", task_id=1)
    strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy(
        cluster_resolver=cluster_resolver)
    ```
docstr: Creates a new GCEClusterResolver object.
  
  This takes in a few parameters and creates a GCEClusterResolver project. It
  will then use these parameters to query the GCE API for the IP addresses of
  each instance in the instance group.
  
  Args:
    project: Name of the GCE project.
    zone: Zone of the GCE instance group.
    instance_group: Name of the GCE instance group.
    port: Port of the listening TensorFlow server (default: 8470)
    task_type: Name of the TensorFlow job this GCE instance group of VM
      instances belong to.
    task_id: The task index for this particular VM, within the GCE
      instance group. In particular, every single instance should be assigned
      a unique ordinal index within an instance group manually so that they
      can be distinguished from each other.
    rpc_layer: The RPC layer TensorFlow should use to communicate across
      instances.
    credentials: GCE Credentials. If nothing is specified, this defaults to
      GoogleCredentials.get_application_default().
    service: The GCE API object returned by the googleapiclient.discovery
      function. (Default: discovery.build('compute', 'v1')). If you specify a
      custom service object, then the credentials parameter will be ignored.
  
  Raises:
    ImportError: If the googleapiclient is not installed.
docstr_tok: ["Creates","a","new","GCEClusterResolver","object",".","This","takes","in","a","few","parameters","and","creates","a","GCEClusterResolver","project",".","It","will","then","use","these","parameters","to","query","the","GCE","API","for","the","IP","addresses","of","each","instance","in","the","instance","group",".","Args",":","project",":","Name","of","the","GCE","project",".","zone",":","Zone","of","the","GCE","instance","group",".","instance_group",":","Name","of","the","GCE","instance","group",".","port",":","Port","of","the","listening","TensorFlow","server","(","default",":","8470",")","task_type",":","Name","of","the","TensorFlow","job","this","GCE","instance","group","of","VM","instances","belong","to",".","task_id",":","The","task","index","for","this","particular","VM",",","within","the","GCE","instance","group",".","In","particular",",","every","single","instance","should","be","assigned","a","unique","ordinal","index","within","an","instance","group","manually","so","that","they","can","be","distinguished","from","each","other",".","rpc_layer",":","The","RPC","layer","TensorFlow","should","use","to","communicate","across","instances",".","credentials",":","GCE","Credentials",".","If","nothing","is","specified",",","this","defaults","to","GoogleCredentials.get_application_default","(",")",".","service",":","The","GCE","API","object","returned","by","the","googleapiclient.discovery","function",".","(","Default",":","discovery.build","(","'compute","'",",","'v1","'",")",")",".","If","you","specify","a","custom","service","object",",","then","the","credentials","parameter","will","be","ignored",".","Raises",":","ImportError",":","If","the","googleapiclient","is","not","installed","."]
code: def __init__(
      self,
      project,
      zone,
      instance_group,
      port,
      task_type="worker",
      task_id=0,
      rpc_layer="grpc",
      credentials="default",
      service=None,
  ):
      """Creates a new GCEClusterResolver object.
  
      This takes in a few parameters and creates a GCEClusterResolver project. It
      will then use these parameters to query the GCE API for the IP addresses of
      each instance in the instance group.
  
      Args:
        project: Name of the GCE project.
        zone: Zone of the GCE instance group.
        instance_group: Name of the GCE instance group.
        port: Port of the listening TensorFlow server (default: 8470)
        task_type: Name of the TensorFlow job this GCE instance group of VM
          instances belong to.
        task_id: The task index for this particular VM, within the GCE
          instance group. In particular, every single instance should be assigned
          a unique ordinal index within an instance group manually so that they
          can be distinguished from each other.
        rpc_layer: The RPC layer TensorFlow should use to communicate across
          instances.
        credentials: GCE Credentials. If nothing is specified, this defaults to
          GoogleCredentials.get_application_default().
        service: The GCE API object returned by the googleapiclient.discovery
          function. (Default: discovery.build('compute', 'v1')). If you specify a
          custom service object, then the credentials parameter will be ignored.
  
      Raises:
        ImportError: If the googleapiclient is not installed.
      """
      self._project = project
      self._zone = zone
      self._instance_group = instance_group
      self._task_type = task_type
      self._task_id = task_id
      self._rpc_layer = rpc_layer
      self._port = port
      self._credentials = credentials
  
      if credentials == "default":
          if _GOOGLE_API_CLIENT_INSTALLED:
              self._credentials = (
                  GoogleCredentials.get_application_default()
              )
  
      if service is None:
          if not _GOOGLE_API_CLIENT_INSTALLED:
              raise ImportError(
                  "googleapiclient must be installed before using the "
                  "GCE cluster resolver"
              )
          self._service = discovery.build(
              "compute", "v1", credentials=self._credentials
          )
      else:
          self._service = service
  
file_path: tensorflow-upstream/tensorflow/python/distribute/cluster_resolver/gce_cluster_resolver.py
imports: 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 1 to create a new GCEClusterResolver object from inherited base classes: ClusterResolver with example: obj = GCEClusterResolver(project, zone, instance_group, port, task_type, task_id, rpc_layer, credentials, service)