code: def test_equal_diag():
      np.random.seed(42)
      for _ in range(3):
          diag = np.random.rand(5)
          x = floatX(np.random.randn(5))
          pots = [
              quadpotential.quad_potential(diag, False),
              quadpotential.quad_potential(1.0 / diag, True),
              quadpotential.quad_potential(np.diag(diag), False),
              quadpotential.quad_potential(np.diag(1.0 / diag), True),
          ]
          if quadpotential.chol_available:
              diag_ = scipy.sparse.csc_matrix(np.diag(1.0 / diag))
              pots.append(quadpotential.quad_potential(diag_, True))
  
          v = np.diag(1.0 / diag).dot(x)
          e = x.dot(np.diag(1.0 / diag).dot(x)) / 2
          for pot in pots:
              v_ = pot.velocity(x)
              e_ = pot.energy(x)
              npt.assert_allclose(v_, v, rtol=1e-6)
              npt.assert_allclose(e_, e, rtol=1e-6)
  
imports: import warnings
  import numpy
  import numpy.testing
  import pytest
  import scipy.sparse
  import pymc
  from pymc.pytensorf import floatX
  from pymc.step_methods.hmc import quadpotential
label_desc: Use image node_id 4 for calling a global function with example usage: test_equal_diag() without return types