class_docstr: Represents a (possibly partial) specification for a TensorFlow device.
  
  `DeviceSpec`s are used throughout TensorFlow to describe where state is stored
  and computations occur. Using `DeviceSpec` allows you to parse device spec
  strings to verify their validity, merge them or compose them programmatically.
  
  Example:
  
  ```python
  # Place the operations on device "GPU:0" in the "ps" job.
  device_spec = DeviceSpec(job="ps", device_type="GPU", device_index=0)
  with tf.device(device_spec.to_string()):
    # Both my_var and squared_var will be placed on /job:ps/device:GPU:0.
    my_var = tf.Variable(..., name="my_variable")
    squared_var = tf.square(my_var)
  ```
  
  With eager execution disabled (by default in TensorFlow 1.x and by calling
  disable_eager_execution() in TensorFlow 2.x), the following syntax
  can be used:
  
  ```python
  tf.compat.v1.disable_eager_execution()
  
  # Same as previous
  device_spec = DeviceSpec(job="ps", device_type="GPU", device_index=0)
  # No need of .to_string() method.
  with tf.device(device_spec):
    my_var = tf.Variable(..., name="my_variable")
    squared_var = tf.square(my_var)
  ```
  
  If a `DeviceSpec` is partially specified, it will be merged with other
  `DeviceSpec`s according to the scope in which it is defined. `DeviceSpec`
  components defined in inner scopes take precedence over those defined in
  outer scopes.
  
  ```python
  gpu0_spec = DeviceSpec(job="ps", device_type="GPU", device_index=0)
  with tf.device(DeviceSpec(job="train").to_string()):
    with tf.device(gpu0_spec.to_string()):
      # Nodes created here will be assigned to /job:ps/device:GPU:0.
    with tf.device(DeviceSpec(device_type="GPU", device_index=1).to_string()):
      # Nodes created here will be assigned to /job:train/device:GPU:1.
  ```
  
  A `DeviceSpec` consists of 5 components -- each of
  which is optionally specified:
  
  * Job: The job name.
  * Replica: The replica index.
  * Task: The task index.
  * Device type: The device type string (e.g. "CPU" or "GPU").
  * Device index: The device index.
class_docstr_tok: ["Represents","a","(","possibly","partial",")","specification","for","a","TensorFlow","device",".","`","DeviceSpec","`","s","are","used","throughout","TensorFlow","to","describe","where","state","is","stored","and","computations","occur",".","Using","`","DeviceSpec","`","allows","you","to","parse","device","spec","strings","to","verify","their","validity",",","merge","them","or","compose","them","programmatically",".","Example",":","``","`","python","#","Place","the","operations","on","device","``","GPU:0","''","in","the","``","ps","''","job",".","device_spec","=","DeviceSpec","(","job=","''","ps","''",",","device_type=","''","GPU","''",",","device_index=0",")","with","tf.device","(","device_spec.to_string","(",")",")",":","#","Both","my_var","and","squared_var","will","be","placed","on","\/job",":","ps\/device",":","GPU:0.","my_var","=","tf.Variable","(","...",",","name=","''","my_variable","''",")","squared_var","=","tf.square","(","my_var",")","``","`","With","eager","execution","disabled","(","by","default","in","TensorFlow","1.x","and","by","calling","disable_eager_execution","(",")","in","TensorFlow","2.x",")",",","the","following","syntax","can","be","used",":","``","`","python","tf.compat.v1.disable_eager_execution","(",")","#","Same","as","previous","device_spec","=","DeviceSpec","(","job=","''","ps","''",",","device_type=","''","GPU","''",",","device_index=0",")","#","No","need","of",".to_string","(",")","method",".","with","tf.device","(","device_spec",")",":","my_var","=","tf.Variable","(","...",",","name=","''","my_variable","''",")","squared_var","=","tf.square","(","my_var",")","``","`","If","a","`","DeviceSpec","`","is","partially","specified",",","it","will","be","merged","with","other","`","DeviceSpec","`","s","according","to","the","scope","in","which","it","is","defined",".","`","DeviceSpec","`","components","defined","in","inner","scopes","take","precedence","over","those","defined","in","outer","scopes",".","``","`","python","gpu0_spec","=","DeviceSpec","(","job=","''","ps","''",",","device_type=","''","GPU","''",",","device_index=0",")","with","tf.device","(","DeviceSpec","(","job=","''","train","''",")",".to_string","(",")",")",":","with","tf.device","(","gpu0_spec.to_string","(",")",")",":","#","Nodes","created","here","will","be","assigned","to","\/job",":","ps\/device",":","GPU:0.","with","tf.device","(","DeviceSpec","(","device_type=","''","GPU","''",",","device_index=1",")",".to_string","(",")",")",":","#","Nodes","created","here","will","be","assigned","to","\/job",":","train\/device",":","GPU:1",".","``","`","A","`","DeviceSpec","`","consists","of","5","components","--","each","of","which","is","optionally","specified",":","*","Job",":","The","job","name",".","*","Replica",":","The","replica","index",".","*","Task",":","The","task","index",".","*","Device","type",":","The","device","type","string","(","e.g",".","``","CPU","''","or","``","GPU","''",")",".","*","Device","index",":","The","device","index","."]
code: def __hash__(self):
      return self._hash
  
imports: from tensorflow.python.util.tf_export import tf_export
  from tensorflow.python import pywrap_tfe
label_desc: Use image node_id 17 for calling the DeviceSpecV2 obj's underlying member method code with example usage: obj.__hash__() and returns: self