human
Complete this python program:
def jacobian(fun, argnum=0):
assistant
#Here is the Python code you requested.

    """Returns a function which computes the Jacobian of `fun` with respect to
    positional argument number `argnum`, which must be a scalar or array. Unlike
    `grad` it is not restricted to scalar-output functions, but also it cannot
    take derivatives with respect to some argument types (like lists or dicts).
    If the input to `fun` has shape (in1, in2, ...) and the output has shape
    (out1, out2, ...) then the Jacobian has shape (out1, out2, ..., in1, in2, ...).
    """
    @attach_name_and_doc(fun, argnum, 'Jacobian')
    @add_error_hints
    def jacfun(*args, **kwargs):
        (vjp, ans) = make_vjp(fun, argnum)(*args, **kwargs)
        ans_vspace = vspace(ans)
        jacobian_shape = (ans_vspace.shape + vspace(args[argnum]).shape)
        grads = map(vjp, ans_vspace.standard_basis())
        return np.reshape(np.stack(grads), jacobian_shape)
    return jacfun