code: def test_jacobian_functions(rng):
      # Compare the analytical Jacobians with their numerical approximations
      h = 1e-8
      nsamples = 50
  
      for transform in regtransforms.values():
          n = transform.get_number_of_parameters()
          dim = transform.get_dim()
  
          expected = np.empty((dim, n))
          theta = rng.uniform(size=(n,))
          T = transform.param_to_matrix(theta)
  
          for j in range(nsamples):
              x = 255 * (rng.uniform(size=(dim,)) - 0.5)
              actual = transform.jacobian(theta, x)
  
              # Approximate with finite differences
              x_hom = np.ones(dim + 1)
              x_hom[:dim] = x[:]
              for i in range(n):
                  dtheta = theta.copy()
                  dtheta[i] += h
                  dT = np.array(transform.param_to_matrix(dtheta))
                  g = (dT - T).dot(x_hom) / h
                  expected[:, i] = g[:dim]
  
              assert_array_almost_equal(actual, expected, decimal=5)
  
      # Test ValueError is raised when theta parameter doesn't have the right
      # length
      for transform in regtransforms.values():
          n = transform.get_number_of_parameters()
          # Wrong number of parameters
          theta = np.zeros(n + 1)
          x = np.zeros(dim)
          assert_raises(ValueError, transform.jacobian, theta, x)
  
file_path: dipy/dipy/align/tests/test_transforms.py
imports: import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises
  from dipy.align.transforms import regtransforms, Transform
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 5 for calling a global function with example usage: test_jacobian_functions(rng) without return types