human
Complete this python program:
def gradgradcheck(func, inputs, grad_outputs, eps=1e-06, atol=1e-05, rtol=0.001):
assistant
#Here is the Python code you requested.

    """Check gradients of gradients computed via small finite differences
    against analytical gradients
    This function checks that backpropagating through the gradients computed
    to the given grad_outputs are correct.
    The check between numerical and analytical has the same behaviour as
    numpy.allclose https://docs.scipy.org/doc/numpy/reference/generated/numpy.allclose.html
    meaning it check that
    absolute(a - n) <= (atol + rtol * absolute(n))
    is true for all elements of analytical gradient a and numerical gradient n.
    Args:
    func: Python function that takes Variable inputs and returns
    a tuple of Variables
    inputs: tuple of Variables
    grad_outputs: tuple of Variables
    eps: perturbation for finite differences
    atol: absolute tolerance
    rtol: relative tolerance
    Returns:
    True if all differences satisfy allclose condition
    """
    def new_func(*input_args):
        input_args = input_args[:(- len(grad_outputs))]
        outputs = func(*input_args)
        outputs = _as_tuple(outputs)
        input_args = tuple((x for x in input_args if (isinstance(x, Variable) and x.requires_grad)))
        grad_inputs = torch.autograd.grad(outputs, input_args, grad_outputs)
        return grad_inputs
    return gradcheck(new_func, (inputs + grad_outputs), eps, atol, rtol)