# Path: autograd/tracer.py
# def trace(start_node, fun, x):
#     def __init__(self, value, fun, args, kwargs, parent_argnums, parents):
#     def initialize_root(self, *args, **kwargs):
#     def new_root(cls, *args, **kwargs):
# def primitive(f_raw):
#     def f_wrapped(*args, **kwargs):
# def register_notrace(trace_type, primitive_fun):
# def notrace_primitive(f_raw):
#     def f_wrapped(*args, **kwargs):
# def find_top_boxed_args(args):
#     def __init__(self):
#     def new_trace(self):
#     def __init__(self, value, trace, node):
#     def __bool__(self):
#     def __str__(self):
#     def register(cls, value_type):
# def new_box(value, trace, node):
# class Node(object):
# class TraceStack(object):
# class Box(object):
# 
# Path: autograd/util.py
# def func(f): return f
# 
# def subval(x, i, v):
#     x_ = list(x)
#     x_[i] = v
#     return tuple(x_)


from itertools import count
from functools import reduce
from .tracer import trace, primitive, toposort, Node, Box, isbox, getval
from .util import func, subval
import warnings
        self.g = jvpmaker(parent_argnums, parent_gs, value, args, kwargs)

    def initialize_root(self, g):
        self.g = g

primitive_jvps = {}
def defjvp_argnums(fun, jvpmaker):
    primitive_jvps[fun] = jvpmaker

def defjvp_argnum(fun, jvpmaker):
    def jvp_argnums(argnums, gs, ans, args, kwargs):
        return sum_outgrads(jvpmaker(argnum, g, ans, args, kwargs)
                            for argnum, g in zip(argnums, gs))
    defjvp_argnums(fun, jvp_argnums)

def defjvp(fun, *jvpfuns, **kwargs):
    argnums = kwargs.get('argnums', count())
    jvps_dict = {argnum : translate_jvp(jvpfun, fun, argnum)
                 for argnum, jvpfun in zip(argnums, jvpfuns)}
    def jvp_argnums(argnums, gs, ans, args, kwargs):
        return sum_outgrads(jvps_dict[argnum](g, ans, *args, **kwargs)
                            for argnum, g in zip(argnums, gs))

    defjvp_argnums(fun, jvp_argnums)

def translate_jvp(jvpfun, fun, argnum):
    if jvpfun is None:
        return lambda g, ans, *a, **k: vspace(ans).zeros()
    elif jvpfun == 'same':
        return (lambda g, ans, *args, **kwargs:

# Path: autograd/tracer.py
# def trace(start_node, fun, x):
#     def __init__(self, value, fun, args, kwargs, parent_argnums, parents):
#     def initialize_root(self, *args, **kwargs):
#     def new_root(cls, *args, **kwargs):
# def primitive(f_raw):
#     def f_wrapped(*args, **kwargs):
# def register_notrace(trace_type, primitive_fun):
# def notrace_primitive(f_raw):
#     def f_wrapped(*args, **kwargs):
# def find_top_boxed_args(args):
#     def __init__(self):
#     def new_trace(self):
#     def __init__(self, value, trace, node):
#     def __bool__(self):
#     def __str__(self):
#     def register(cls, value_type):
# def new_box(value, trace, node):
# class Node(object):
# class TraceStack(object):
# class Box(object):
# 
# Path: autograd/util.py
# def func(f): return f
# 
# def subval(x, i, v):
#     x_ = list(x)
#     x_[i] = v
#     return tuple(x_)


# Path: autograd/core.py
from itertools import count
from functools import reduce
from .tracer import trace, primitive, toposort, Node, Box, isbox, getval
from .util import func, subval
import warnings

        self.g = jvpmaker(parent_argnums, parent_gs, value, args, kwargs)

    def initialize_root(self, g):
        self.g = g

primitive_jvps = {}
def defjvp_argnums(fun, jvpmaker):
    primitive_jvps[fun] = jvpmaker

def defjvp_argnum(fun, jvpmaker):
    def jvp_argnums(argnums, gs, ans, args, kwargs):
        return sum_outgrads(jvpmaker(argnum, g, ans, args, kwargs)
                            for argnum, g in zip(argnums, gs))
    defjvp_argnums(fun, jvp_argnums)

def defjvp(fun, *jvpfuns, **kwargs):
    argnums = kwargs.get('argnums', count())
    jvps_dict = {argnum : translate_jvp(jvpfun, fun, argnum)
                 for argnum, jvpfun in zip(argnums, jvpfuns)}
    def jvp_argnums(argnums, gs, ans, args, kwargs):
        return sum_outgrads(jvps_dict[argnum](g, ans, *args, **kwargs)
                            for argnum, g in zip(argnums, gs))

    defjvp_argnums(fun, jvp_argnums)

def translate_jvp(jvpfun, fun, argnum):
    if jvpfun is None:
        return lambda g, ans, *a, **k: vspace(ans).zeros()
    elif jvpfun == 'same':
        return (lambda g, ans, *args, **kwargs:

                fun(*subval(args, argnum, g), **kwargs))