code: def testCheckValid(self):
      device.check_valid("/job:foo/replica:0")
  
      with self.assertRaisesRegex(
          ValueError, "invalid literal for int"
      ):
          device.check_valid("/job:j/replica:foo")
  
      with self.assertRaisesRegex(
          ValueError, "invalid literal for int"
      ):
          device.check_valid("/job:j/task:bar")
  
      # Assume no one will register a device type named "barcpugpu"
      with self.assertRaisesRegex(
          ValueError, "Unknown attribute 'barcpugpu'"
      ):
          device.check_valid("/barcpugpu:muu/baz:2")
  
      with self.assertRaisesRegex(
          ValueError, "Multiple device types are not allowed"
      ):
          device.check_valid("/cpu:0/device:GPU:2")
  
file_path: tensorflow/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 3 for calling the DeviceTest obj's underlying member method code with example usage: obj.testCheckValid() without return types