code: def test_compute_energy_ssd_2d():
      sh = (32, 32)
  
      # Select arbitrary centers
      c_f = np.asarray(sh) / 2
      c_g = c_f + 0.5
  
      # Compute the identity vector field I(x) = x in R^2
      x_0 = np.asarray(range(sh[0]))
      x_1 = np.asarray(range(sh[1]))
      X = np.ndarray(sh + (2,), dtype=np.float64)
      O = np.ones(sh)
      X[..., 0] = x_0[:, None] * O
      X[..., 1] = x_1[None, :] * O
  
      # Compute the gradient fields of F and G
      grad_F = X - c_f
      grad_G = X - c_g
  
      # Compute F and G
      F = 0.5 * np.sum(grad_F**2, -1)
      G = 0.5 * np.sum(grad_G**2, -1)
  
      # Note: this should include the energy corresponding to the
      # regularization term, but it is discarded in ANTS (they just
      # consider the data term, which is not the objective function
      # being optimized). This test case should be updated after
      # further investigation
      expected = ((F - G) ** 2).sum()
      actual = ssd.compute_energy_ssd_2d(
          np.array(F - G, dtype=floating)
      )
      assert_almost_equal(expected, actual)
  
file_path: dipy/dipy/align/tests/test_sumsqdiff.py
imports: import numpy
  from dipy.align import floating
  from dipy.align import sumsqdiff
  from numpy.testing import assert_equal, assert_almost_equal, assert_array_almost_equal, assert_allclose
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 7 for calling a global function with example usage: test_compute_energy_ssd_2d() without return types