def _get_ps_specs(nodes, min_nb_ps, max_nb_ps, using_cpu_only, grpc_port):
    """ Returns the list of ip:port for all ps nodes """
    ps_specs = []
    if using_cpu_only:
        for node_ip in nodes.values():
            for ps_ix in range(max(min_nb_ps, max_nb_ps)):
                ps_specs += ['%s:%d' % (node_ip, grpc_port + 100 + ps_ix)]
    else:
        node_ips = list(nodes.values())
        ps_by_node = {node_ip: [] for node_ip in nodes.values()}
        for ps_ix in range(min_nb_ps):
            node_ip = node_ips[ps_ix % len(node_ips)]
            ps_by_node[node_ip] += ['%s:%d' % (node_ip, grpc_port + 100 +
                len(ps_by_node[node_ip]))]
        for ps_ix in range(min_nb_ps, max_nb_ps):
            node_ip = node_ips[ps_ix % len(node_ips)]
            if not ps_by_node[node_ip]:
                ps_by_node[node_ip] += ['%s:%d' % (node_ip, grpc_port + 100 +
                    len(ps_by_node[node_ip]))]
        for node_ip in ps_by_node:
            ps_specs += ps_by_node[node_ip]
    return ps_specs
