code: def run_permutations(tested_var, target_var, model_intercept):
      """Compute the Mean Squared Error between cumulative Density Function \
      as a proof of consistency of the permutation algorithm."""
      all_mse = []
      all_kstest_pvals = []
  
      for i, n_perm in enumerate(np.repeat(PERM_RANGES, 10)):
          if model_intercept:
              h0 = permuted_ols_with_intercept(
                  tested_var, target_var, n_perm, i
              )
              df = N_SAMPLES - 2
          else:
              h0 = permuted_ols_no_intercept(
                  tested_var, target_var, n_perm, i
              )
              df = N_SAMPLES - 1
  
          h0_intercept = h0[0, :]
          kstest_pval, mse = ks_stat_and_mse(df, h0_intercept)
  
          all_kstest_pvals.append(kstest_pval)
          all_mse.append(mse)
  
      return all_kstest_pvals, all_mse
  
imports: import nibabel
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_less, assert_equal
  from scipy import stats
  from nilearn.conftest import _rng
  from nilearn.maskers import NiftiMasker
  from nilearn.mass_univariate import permuted_ols
label_desc: Use image node_id 10 for calling a global function with example usage: run_permutations(tested_var, target_var, model_intercept) and returns: all_kstest_pvals,  all_mse