def _assert_grad_equal(self, f_str, tensors, rtol=1e-2, atol=1e-5, next_error=None):

        def debug_msg(count):
            msg = ''
            msg += (count,) % 'Error at tensor x%s' + '\n'
            msg += pprint.pformat(tensors) + '\n'
            grad_op_trees = self._get_autodiff_grads_and_val(f_str, tensors,
                                                             get_op_tree=True)
            grad_op_tree = grad_op_trees[0][count - 1]
            msg += grad_op_tree.pp() + '\n'
            return msg

        # gradients
        autodiff_grads_and_val = self._get_autodiff_grads_and_val(
            f_str, tensors, next_error=next_error)
        numerical_grads_and_val = self._get_numerical_grads_and_val(
            f_str, tensors, next_error=next_error)

        # asserts
        assert(len(autodiff_grads_and_val) == len(numerical_grads_and_val))

        # check function values
        numerical_grads_and_val[1] = numerical_grads_and_val[
            1].reshape(autodiff_grads_and_val[1].shape)
        assert np.allclose(autodiff_grads_and_val[1].astype(self.dtype),
                           numerical_grads_and_val[1].astype(self.dtype),
                           rtol=rtol, atol=atol)

        # check gradient
        count = 0
        for autodiff_grad, numerical_grad in zip(autodiff_grads_and_val[0],
                                                 numerical_grads_and_val[0]):
            count += 1
            # print count
            if not np.allclose(autodiff_grad.astype(self.dtype), numerical_grad.astype(self.dtype),
                               rtol=rtol, atol=atol):
                raise ValueError(debug_msg(count))

    ###################
    # actual test cases
    ###################
dataset/ETHPy150Open NervanaSystems/neon/neon/backends/tests/test_autodiff_extra.py/TestAutodiff._assert_grad_equal/swapped operands of `%`