code: def testPS2TasksWithClusterDef(self):
      with ops.device(
          device_setter.replica_device_setter(
              cluster=self._cluster_spec.as_cluster_def()
          )
      ):
          v = variables.Variable([1, 2])
          w = variables.Variable([2, 1])
          a = v + w
          self.assertDeviceEqual("/job:ps/task:0", v.device)
          self.assertDeviceEqual("/job:ps/task:0", v.initializer.device)
          self.assertDeviceEqual("/job:ps/task:1", w.device)
          self.assertDeviceEqual("/job:ps/task:1", w.initializer.device)
          self.assertDeviceEqual("/job:worker", a.device)
  
file_path: tensorflow/tensorflow/python/training/device_setter_test.py
imports: from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import device_setter
  from tensorflow.python.training import server_lib
label_desc: Use image node_id 8 for calling the DeviceSetterTest obj's underlying member method code with example usage: obj.testPS2TasksWithClusterDef() without return types