def compare_tensors(func, y, t, outputs, deriv=False, tol=0.):
    be = NervanaObject.be
    temp = be.empty(outputs.shape)
    dtypeu = np.float32
    if deriv is True:
        temp[:] = func.bprop(be.array(dtypeu(y)), be.array(dtypeu(t)))
    else:
        # try:
        temp[:] = func(be.array(dtypeu(y)), be.array(dtypeu(t)))
        # except:
        #     import ipdb; ipdb.set_trace()
    cond = np.sum(np.abs(temp.get() - outputs) <= tol)
    assert cond == np.prod(outputs.shape)
dataset/ETHPy150Open NervanaSystems/neon/tests/test_costs.py/compare_tensors/original