def METHOD_NAME(func,terminals,h=1e-6,rtol=1e-2,atol=1e-3):
    #sample some random parameters of the appropriate length
    if isinstance(func,ad.ADFunctionInterface):
        params=[]
        for i in range(len(terminals)):
            try:
                N = func.n_in(i)
                if N < 0:
                    N = 10
            except NotImplementedError:
                N = 10
            params.append(torch.randn(N))
    else:
        N = 10
        params = [torch.randn(N) for i in range(len(terminals))]
    for p in params:
        p.requires_grad_(True)
    torch.autograd.gradcheck(ADModule.apply,tuple([func,terminals]+params),eps=h,atol=atol,rtol=rtol,raise_exception=True)