code: def test_icm_square(rng):
      nclasses = 4
      max_iter = 10
  
      com = ConstantObservationModel()
      icm = IteratedConditionalModes()
  
      initial_segmentation = create_square()
      square_1 = create_square_uniform(rng)
  
      mu, sigma = com.seg_stats(
          square_1, initial_segmentation, nclasses
      )
      sigmasq = sigma**2
      npt.assert_(mu[0] >= 0.0)
      npt.assert_(mu[1] >= 0.0)
      npt.assert_(mu[2] >= 0.0)
      npt.assert_(mu[3] >= 0.0)
      npt.assert_(sigmasq[0] >= 0.0)
      npt.assert_(sigmasq[1] >= 0.0)
      npt.assert_(sigmasq[2] >= 0.0)
      npt.assert_(sigmasq[3] >= 0.0)
  
      negll = com.negloglikelihood(square_1, mu, sigmasq, nclasses)
  
      final_segmentation_1 = np.empty_like(square_1)
      final_segmentation_2 = np.empty_like(square_1)
  
      beta = 0.0
  
      for i in range(max_iter):
          print("\n")
          print(">> Iteration: " + str(i))
          print("\n")
  
          final_segmentation_1, energy_1 = icm.icm_ising(
              negll, beta, initial_segmentation
          )
          initial_segmentation = final_segmentation_1
  
      beta = 2
      initial_segmentation = create_square()
  
      for j in range(max_iter):
          print("\n")
          print(">> Iteration: " + str(j))
          print("\n")
  
          final_segmentation_2, energy_2 = icm.icm_ising(
              negll, beta, initial_segmentation
          )
          initial_segmentation = final_segmentation_2
  
      difference_map = np.abs(
          final_segmentation_1 - final_segmentation_2
      )
      npt.assert_(np.abs(np.sum(difference_map)) != 0)
  
file_path: dipy/dipy/segment/tests/test_mrf.py
imports: import numpy
  import numpy.testing
  from dipy.data import get_fnames
  from dipy.sims.voxel import add_noise
  from dipy.segment.mrf import ConstantObservationModel, IteratedConditionalModes
  from dipy.segment.tissue import TissueClassifierHMRF
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 8 for calling a global function with example usage: test_icm_square(rng) without return types