Returns the list of devices that multi-replica code should use.
  :param devices: list of string device names, e.g. ["/GPU:0"]
      If the user specifies this, `infer_devices` checks that it is
      valid, and then uses this user-specified list.
      If the user does not specify this, infer_devices uses:
          - All available GPUs, if there are any
          - CPU otherwise

def infer_devices(devices=None):
  """
  Returns the list of devices that multi-replica code should use.
  :param devices: list of string device names, e.g. ["/GPU:0"]
      If the user specifies this, `infer_devices` checks that it is
      valid, and then uses this user-specified list.
      If the user does not specify this, infer_devices uses:
          - All available GPUs, if there are any
          - CPU otherwise
  """
  if devices is None:
    devices = get_available_gpus()
    if len(devices) == 0:
      warnings.warn("No GPUS, running on CPU")
      # Set device to empy string, tf will figure out whether to use
      # XLA or not, etc., automatically
      devices = [""]
  else:
    assert len(devices) > 0
    for device in devices:
      assert isinstance(device, six.string_types), type(device)
  return devices