code: def testMerge(self, DeviceSpec):  # pylint: disable=invalid-name
      d = DeviceSpec.from_string(
          "/job:muu/task:1/device:MyFunnyDevice:2"
      )
      self.assertEqual(
          "/job:muu/task:1/device:MyFunnyDevice:2", d.to_string()
      )
  
      if not context.executing_eagerly():
          with ops.device(device.merge_device("/device:GPU:0")):
              var1 = variables.Variable(1.0)
              self.assertEqual("/device:GPU:0", var1.device)
              with ops.device(device.merge_device("/job:worker")):
                  var2 = variables.Variable(1.0)
                  self.assertEqual(
                      "/job:worker/device:GPU:0", var2.device
                  )
                  with ops.device(device.merge_device("/device:CPU:0")):
                      var3 = variables.Variable(1.0)
                      self.assertEqual(
                          "/job:worker/device:CPU:0", var3.device
                      )
                      with ops.device(device.merge_device("/job:ps")):
                          var4 = variables.Variable(1.0)
                          self.assertEqual(
                              "/job:ps/device:CPU:0", var4.device
                          )
  
file_path: tensorflow-upstream/tensorflow/python/framework/device_test.py
imports: from absl.testing import parameterized
  from tensorflow.python.eager import context
  from tensorflow.python.framework import device
  from tensorflow.python.framework import device_spec
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 1 for calling the DeviceTest obj's underlying member method code with example usage: obj.testMerge(DeviceSpec) without return types