code: def test_hess(self):
      for test_params in self.params:
          he = self.mod.hessian(test_params)
          hefd = numdiff.approx_fprime_cs(test_params, self.mod.score)
          assert_almost_equal(he, hefd, decimal=DEC8)
  
          # NOTE: notice the accuracy below
          assert_almost_equal(he, hefd, decimal=7)
          hefd = numdiff.approx_fprime(
              test_params, self.mod.score, centered=True
          )
          assert_allclose(he, hefd, rtol=1e-9)
          hefd = numdiff.approx_fprime(
              test_params, self.mod.score, centered=False
          )
          assert_almost_equal(he, hefd, decimal=4)
  
          hescs = numdiff.approx_fprime_cs(
              test_params.ravel(), self.mod.score
          )
          assert_allclose(he, hescs, rtol=1e-13)
  
          hecs = numdiff.approx_hess_cs(
              test_params.ravel(), self.mod.loglike
          )
          assert_allclose(he, hecs, rtol=1e-9)
  
          # NOTE: Look at the lack of precision - default epsilon not always
          # best
          grad = self.mod.score(test_params)
          hecs, gradcs = numdiff.approx_hess1(
              test_params, self.mod.loglike, 1e-6, return_grad=True
          )
          assert_almost_equal(he, hecs, decimal=1)
          assert_almost_equal(grad, gradcs, decimal=1)
          hecs, gradcs = numdiff.approx_hess2(
              test_params, self.mod.loglike, 1e-4, return_grad=True
          )
          assert_almost_equal(he, hecs, decimal=3)
          assert_almost_equal(grad, gradcs, decimal=1)
          hecs = numdiff.approx_hess3(
              test_params, self.mod.loglike, 1e-5
          )
          assert_almost_equal(he, hecs, decimal=4)
  
imports: import numpy
  from numpy.testing import assert_allclose, assert_almost_equal
  import statsmodels.api
  from statsmodels.tools import numdiff
  from statsmodels.tools.numdiff import approx_fprime, approx_fprime_cs, approx_hess_cs, _approx_fprime_scalar, _approx_fprime_cs_scalar
label_desc: Use image node_id 2 for calling the CheckGradLoglikeMixin obj's underlying member method code with example usage: obj.test_hess() without return types