code: def _assert_grad_equal(
      self, f_str, tensors, rtol=1e-2, atol=1e-5, next_error=None
  ):
      def debug_msg(count):
          msg = ""
          msg += "Error at tensor x%s" % (count,) + "\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 allclose_with_out(
          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))
  
imports: from builtins import zip
  import numpy
  import pprint
  import pytest
  from neon import NervanaObject
  from neon.backends.autodiff import Autodiff
  from utils import allclose_with_out
label_desc: Use image node_id 6 for calling the TestAutodiff obj's underlying member method code with example usage: obj._assert_grad_equal(f_str, tensors, rtol, atol, next_error) and returns: msg