code: def test_exceptions():
      H = ParzenJointHistogram(32)
      valid = np.empty((2, 2, 2), dtype=np.float64)
      invalid = np.empty((2, 2, 2, 2), dtype=np.float64)
  
      # Test exception from `ParzenJointHistogram.update_pdfs_dense`
      assert_raises(ValueError, H.update_pdfs_dense, valid, invalid)
      assert_raises(ValueError, H.update_pdfs_dense, invalid, valid)
      assert_raises(ValueError, H.update_pdfs_dense, invalid, invalid)
  
      # Test exception from `ParzenJointHistogram.update_gradient_dense`
      for shape in [(5, 5), (5, 5, 5)]:
          dim = len(shape)
          grid2world = np.eye(dim + 1)
          transform = regtransforms[("ROTATION", dim)]
          theta = transform.get_identity_parameters()
          valid_img = np.empty(shape, dtype=np.float64)
          valid_grad = np.empty(shape + (dim,), dtype=np.float64)
  
          invalid_img = np.empty((2, 2, 2, 2), dtype=np.float64)
          invalid_grad_type = np.empty_like(valid_grad, dtype=np.int32)
          invalid_grad_dim = np.empty(
              shape + (dim + 1,), dtype=np.float64
          )
  
          for s, m, g in [
              (valid_img, valid_img, invalid_grad_type),
              (valid_img, valid_img, invalid_grad_dim),
              (invalid_img, valid_img, valid_grad),
              (invalid_img, invalid_img, invalid_grad_type),
              (invalid_img, invalid_img, invalid_grad_dim),
          ]:
              assert_raises(
                  ValueError,
                  H.update_gradient_dense,
                  theta,
                  transform,
                  s,
                  m,
                  grid2world,
                  g,
              )
  
      # Test exception from `ParzenJointHistogram.update_gradient_dense`
      nsamples = 2
      for dim in [2, 3]:
          transform = regtransforms[("ROTATION", dim)]
          theta = transform.get_identity_parameters()
          valid_vals = np.empty((nsamples,), dtype=np.float64)
          valid_grad = np.empty((nsamples, dim), dtype=np.float64)
          valid_points = np.empty((nsamples, dim), dtype=np.float64)
  
          invalid_grad_type = np.empty((nsamples, dim), dtype=np.int32)
          invalid_grad_dim = np.empty(
              (nsamples, dim + 2), dtype=np.float64
          )
          invalid_grad_len = np.empty(
              (nsamples + 1, dim), dtype=np.float64
          )
          invalid_vals = np.empty((nsamples + 1), dtype=np.float64)
          invalid_points_dim = np.empty(
              (nsamples, dim + 2), dtype=np.float64
          )
          invalid_points_len = np.empty(
              (nsamples + 1, dim), dtype=np.float64
          )
  
          C = [
              (invalid_vals, valid_vals, valid_points, valid_grad),
              (valid_vals, invalid_vals, valid_points, valid_grad),
              (valid_vals, valid_vals, invalid_points_dim, valid_grad),
              (
                  valid_vals,
                  valid_vals,
                  invalid_points_dim,
                  invalid_grad_dim,
              ),
              (valid_vals, valid_vals, invalid_points_len, valid_grad),
              (valid_vals, valid_vals, valid_points, invalid_grad_type),
              (valid_vals, valid_vals, valid_points, invalid_grad_dim),
              (valid_vals, valid_vals, valid_points, invalid_grad_len),
          ]
  
          for s, m, p, g in C:
              assert_raises(
                  ValueError,
                  H.update_gradient_sparse,
                  theta,
                  transform,
                  s,
                  m,
                  p,
                  g,
              )
  
imports: import numpy
  import scipy
  from functools import reduce
  from operator import mul
  from dipy.core.ndindex import ndindex
  from dipy.core.interpolation import interpolate_scalar_2d, interpolate_scalar_3d
  from dipy.data import get_fnames
  from dipy.align import vector_fields
  from dipy.align.transforms import regtransforms
  from dipy.align.parzenhist import ParzenJointHistogram, cubic_spline, cubic_spline_derivative, sample_domain_regular
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_almost_equal, assert_equal, assert_raises
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 10 for calling a global function with example usage: test_exceptions() without return types