def backward_pass(start_node, end_node, tape):
    if not isinstance(end_node, Node) or tape not in end_node.tapes:
        warnings.warn("Output seems independent of input. Returning zero gradient.")
        return zeros_like(start_node)
    if type(end_node) is not FloatNode:
        try:
            end_node = FloatNode.cast(end_node, 1.0)
        except TypeError:
            raise TypeError(
                "Output type {} can't be cast to float. "
                "Function grad requires a scalar-valued function. "
                "Try jacobian or elementwise_grad.".format(type(end_node.value)))

    for node in tape:
        node.outgrads = []
    end_node.tapes[tape].outgrads = [1.0]

    tape.complete = True
    for node in tape[::-1]:
        if node.outgrads:
            cur_outgrad = node.sum_outgrads()
            assert type(new_node(getval(cur_outgrad))) == node.node_type, \
                "Types are {0} and {1}".format(type(new_node(getval(cur_outgrad))), node.node_type)
            for gradfun, parent in node.parent_grad_ops:
                og = cast_to_node_type(gradfun(cur_outgrad), parent.node_type, parent.node_value)
                parent.outgrads.append(og)
    return cur_outgrad
dataset/ETHPy150Open HIPS/autograd/autograd/core.py/backward_pass/original