code: def list_devices(device_type=None):
      """Return all the available devices based on the device type.
  
      Note that this should return the global devices in a distributed setting.
  
      Args:
          device_type: string of `"cpu"`, `"gpu"` or `"tpu"`. Default to `gpu` or
          `tpu` if available when device_type is not provided. Otherwise will
          return the `cpu` devices.
  
      Return:
          List of devices that are available for distribute computation.
      """
      device_type = device_type.upper() if device_type else "CPU"
  
      # DTensor doesn't support getting global devices, even when knowing the
      # Mesh. Use TF API instead to get global devices. Coordinator service is
      # enabled by default with DTensor, so that list_logical_devices() returns
      # a list of global devices. More context can be found in b/254911601.
      tf_devices = tf.config.list_logical_devices(
          device_type=device_type
      )
      return [
          f"{device.device_type.lower()}:{device.name.split(':')[-1]}"
          for device in tf_devices
      ]
  
imports: import tensorflow
  from tensorflow.experimental import dtensor
label_desc: Use image node_id 1 for calling a global function with example usage: list_devices(device_type) and returns: unknown