code: def test_mppca_returned_sigma(rng):
      DWIgt = rfiw_phantom(gtab, snr=None, rng=rng)
      std_gt = 0.02
      noise = std_gt * rng.standard_normal(DWIgt.shape)
      DWInoise = DWIgt + noise
  
      # patch radius (2: #samples > #features, 1: #samples < #features)
      for PR in [2, 1]:
          # Case that sigma is estimated using mpPCA
          if PR == 1:
              patch_radius_arr = create_patch_radius_arr(DWInoise, PR)
              patch_size = compute_patch_size(patch_radius_arr)
              num_samples = compute_num_samples(patch_size)
              spr = compute_suggested_patch_radius(DWInoise, patch_size)
  
          if PR == 1:
              with warnings.catch_warnings():
                  warnings.filterwarnings(
                      "ignore",
                      message=dimensionality_problem_message(
                          DWInoise, num_samples, spr
                      ),
                      category=UserWarning,
                  )
                  DWIden0, sigma = mppca(
                      DWInoise, patch_radius=PR, return_sigma=True
                  )
          else:
              DWIden0, sigma = mppca(
                  DWInoise, patch_radius=PR, return_sigma=True
              )
          msigma = np.mean(sigma)
          std_error = abs(msigma - std_gt) / std_gt * 100
  
          # if #noise_eigenvals >> #signal_eigenvals, variance should be well estimated
          # this is more likely achieved if #samples > #features
          if PR > 1:
              assert_(std_error < 5)
          else:  # otherwise, variance estimate may be wrong
              pass
  
          # Case that sigma is inputted (sigma outputted should be the same as the
          # one inputted)
          if PR == 1:
              with warnings.catch_warnings():
                  warnings.filterwarnings(
                      "ignore",
                      message=dimensionality_problem_message(
                          DWInoise, num_samples, spr
                      ),
                      category=UserWarning,
                  )
                  DWIden1, rsigma = genpca(
                      DWInoise,
                      sigma=sigma,
                      tau_factor=None,
                      patch_radius=PR,
                      return_sigma=True,
                  )
          else:
              DWIden1, rsigma = genpca(
                  DWInoise,
                  sigma=sigma,
                  tau_factor=None,
                  patch_radius=PR,
                  return_sigma=True,
              )
  
          assert_array_almost_equal(rsigma, sigma)
  
          # DWIden1 should be very similar to DWIden0
          rmse_den = np.sum(np.abs(DWIden1 - DWIden0)) / np.sum(
              np.abs(DWIden0)
          )
          rmse_ref = np.sum(np.abs(DWIden1 - DWIgt)) / np.sum(
              np.abs(DWIgt)
          )
          assert_(rmse_den < rmse_ref)
  
imports: import warnings
  import numpy
  import scipy.special
  from numpy.testing import assert_, assert_equal, assert_raises, assert_array_almost_equal, assert_warns
  from dipy.denoise.localpca import dimensionality_problem_message, create_patch_radius_arr, compute_patch_size, compute_num_samples, compute_suggested_patch_radius, localpca, mppca, genpca, _pca_classifier
  from dipy.sims.voxel import multi_tensor
  from dipy.core.gradients import gradient_table, generate_bvecs
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 21 for calling a global function with example usage: test_mppca_returned_sigma(rng) without return types