# Path: autograd/util.py
# def subvals(x, ivs):
#     x_ = list(x)
#     for i, v in ivs:
#         x_[i] = v
#     return tuple(x_)
# 
# def toposort(end_node, parents=operator.attrgetter('parents')):
#     child_counts = {}
#     stack = [end_node]
#     while stack:
#         node = stack.pop()
#         if node in child_counts:
#             child_counts[node] += 1
#         else:
#             child_counts[node] = 1
#             stack.extend(parents(node))
# 
#     childless_nodes = [end_node]
#     while childless_nodes:
#         node = childless_nodes.pop()
#         yield node
#         for parent in parents(node):
#             if child_counts[parent] == 1:
#                 childless_nodes.append(parent)
#             else:
#                 child_counts[parent] -= 1
# 
# Path: autograd/tracer.py
# def trace(start_node, fun, x):
#     with trace_stack.new_trace() as t:
#         start_box = new_box(x, t, start_node)
#         end_box = fun(start_box)
#         if isbox(end_box) and end_box._trace == start_box._trace:
#             return end_box._value, end_box._node
#         else:
#             warnings.warn("Output seems independent of input.")
#             return end_box, None
# 
# class Node(object):
#     __slots__ = []
#     def __init__(self, value, fun, args, kwargs, parent_argnums, parents):
#         assert False
# 
#     def initialize_root(self, *args, **kwargs):
#         assert False
# 
#     @classmethod
#     def new_root(cls, *args, **kwargs):
#         root = cls.__new__(cls)
#         root.initialize_root(*args, **kwargs)
#         return root


from itertools import repeat
from autograd.wrap_util import wraps
from autograd.util import subvals, toposort
from autograd.tracer import trace, Node
from functools import partial

class ConstGraphNode(Node):
    __slots__ = ['parents', 'partial_fun']
    def __init__(self, value, fun, args, kwargs, parent_argnums, parents):

# Path: autograd/util.py
# def subvals(x, ivs):
#     x_ = list(x)
#     for i, v in ivs:
#         x_[i] = v
#     return tuple(x_)
# 
# def toposort(end_node, parents=operator.attrgetter('parents')):
#     child_counts = {}
#     stack = [end_node]
#     while stack:
#         node = stack.pop()
#         if node in child_counts:
#             child_counts[node] += 1
#         else:
#             child_counts[node] = 1
#             stack.extend(parents(node))
# 
#     childless_nodes = [end_node]
#     while childless_nodes:
#         node = childless_nodes.pop()
#         yield node
#         for parent in parents(node):
#             if child_counts[parent] == 1:
#                 childless_nodes.append(parent)
#             else:
#                 child_counts[parent] -= 1
# 
# Path: autograd/tracer.py
# def trace(start_node, fun, x):
#     with trace_stack.new_trace() as t:
#         start_box = new_box(x, t, start_node)
#         end_box = fun(start_box)
#         if isbox(end_box) and end_box._trace == start_box._trace:
#             return end_box._value, end_box._node
#         else:
#             warnings.warn("Output seems independent of input.")
#             return end_box, None
# 
# class Node(object):
#     __slots__ = []
#     def __init__(self, value, fun, args, kwargs, parent_argnums, parents):
#         assert False
# 
#     def initialize_root(self, *args, **kwargs):
#         assert False
# 
#     @classmethod
#     def new_root(cls, *args, **kwargs):
#         root = cls.__new__(cls)
#         root.initialize_root(*args, **kwargs)
#         return root


# Path: autograd/misc/tracers.py
from itertools import repeat
from autograd.wrap_util import wraps
from autograd.util import subvals, toposort
from autograd.tracer import trace, Node
from functools import partial


class ConstGraphNode(Node):
    __slots__ = ['parents', 'partial_fun']
    def __init__(self, value, fun, args, kwargs, parent_argnums, parents):

        args = subvals(args, zip(parent_argnums, repeat(None)))