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

    """Builds a function that returns the gradient of the first output and the
    (unmodified) second output of a function that returns two outputs.
    """
    def grad_and_aux_fun(*args, **kwargs):
        saved = (lambda : None)
        def return_val_save_aux(*args, **kwargs):
            (val, saved.aux) = fun(*args, **kwargs)
            return val
        gradval = grad(return_val_save_aux, argnum)(*args, **kwargs)
        return (gradval, saved.aux)
    return grad_and_aux_fun