code: def check_valid(spec):
      """Check that a device spec is valid.
  
      Args:
        spec: a string.
  
      Raises:
        An exception if the spec is invalid.
      """
      # Construct a DeviceSpec.  It will assert a failure if spec is invalid.
      DeviceSpec.from_string(spec)
  
file_path: tensorflow/tensorflow/python/framework/device.py
imports: from tensorflow.python import tf2
  from tensorflow.python.framework import device_spec
label_desc: Use image node_id 1 for calling a global function with example usage: check_valid(spec) without return types