def distributed_gradients(output_node, node_list, scheduler_policy=None):
    'Take gradient of output node with respect to each node in node_list.\n\n    Parameters\n    ----------\n    output_node: output node that we are taking derivative of.\n    node_list: list of nodes that we are taking derivative wrt.\n\n    Returns\n    -------\n    A list of gradient values, one for each node in node_list respectively.\n\n    '
    from .OnesLike import oneslike_op
    node_to_output_grads_list = {}
    node_to_output_grads_list[output_node] = [oneslike_op(output_node)]
    node_to_output_grad = {}
    reverse_topo_order = reversed(find_topo_sort([output_node]))
    for node in reverse_topo_order:
        output_grad = sum_node_list(node_to_output_grads_list[node])
        node_to_output_grad[node] = output_grad
        input_grads_list = node.op.gradient(node, output_grad)
        for i in range(len(node.inputs)):
            if (node.inputs[i] not in node_to_output_grads_list):
                node_to_output_grads_list[node.inputs[i]] = []
            node_to_output_grads_list[node.inputs[i]].append(input_grads_list[i])
    if (scheduler_policy == 'swap'):
        for node in node_list:
            if node.swap:
                node_to_output_grad[node].swap = True
    grad_node_list = [distributed_communicate_op(node_to_output_grad[node]) for node in node_list]
    return grad_node_list
Take gradient of output node with respect to each node in node_list.

Parameters
----------
output_node: output node that we are taking derivative of.
node_list: list of nodes that we are taking derivative wrt.

Returns
-------
A list of gradient values, one for each node in node_list respectively.
def distributed_gradients(output_node, node_list, scheduler_policy=None):
    'Take gradient of output node with respect to each node in node_list.\n\n    Parameters\n    ----------\n    output_node: output node that we are taking derivative of.\n    node_list: list of nodes that we are taking derivative wrt.\n\n    Returns\n    -------\n    A list of gradient values, one for each node in node_list respectively.\n\n    '
    from .OnesLike import oneslike_op
    node_to_output_grads_list = {}
    node_to_output_grads_list[output_node] = [oneslike_op(output_node)]
    node_to_output_grad = {}
    reverse_topo_order = reversed(find_topo_sort([output_node]))
    for node in reverse_topo_order:
        output_grad = sum_node_list(node_to_output_grads_list[node])
        node_to_output_grad[node] = output_grad
        input_grads_list = node.op.gradient(node, output_grad)
        for i in range(len(node.inputs)):
            if (node.inputs[i] not in node_to_output_grads_list):
                node_to_output_grads_list[node.inputs[i]] = []
            node_to_output_grads_list[node.inputs[i]].append(input_grads_list[i])
    if (scheduler_policy == 'swap'):
        for node in node_list:
            if node.swap:
                node_to_output_grad[node].swap = True
    grad_node_list = [distributed_communicate_op(node_to_output_grad[node]) for node in node_list]
    return grad_node_list