<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_all_reduce_device_prefixes(job_name, num_tasks):
 """Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spells out the full host name without adding the device. e.g. "/job:worker/task:0" """

    if job_name != "localhost":
        return ["/job:%s/task:%d" % (job_name, d) for d in range(0, num_tasks)]
    else:
        assert num_tasks == 1
        return ["/job:%s" % job_name]