code: def test_cluster_permutation_t_test(numba_conditional, stat_fun):
      """Test cluster level permutations T-test."""
      (
          condition1_1d,
          condition2_1d,
          condition1_2d,
          condition2_2d,
      ) = _get_conditions()
  
      # use a very large sigma to make sure Ts are not independent
      for condition1, p in (
          (condition1_1d, 0.01),
          (condition1_2d, 0.01),
      ):
          # these are so significant we can get away with fewer perms
          (
              T_obs,
              clusters,
              cluster_p_values,
              hist,
          ) = permutation_cluster_1samp_test(
              condition1,
              n_permutations=100,
              tail=0,
              seed=1,
              out_type="mask",
              buffer_size=None,
          )
          assert_equal(np.sum(cluster_p_values < 0.05), 1)
          p_min = np.min(cluster_p_values)
          assert_allclose(p_min, p, atol=1e-6)
  
          (
              T_obs_pos,
              c_1,
              cluster_p_values_pos,
              _,
          ) = permutation_cluster_1samp_test(
              condition1,
              n_permutations=100,
              tail=1,
              threshold=1.67,
              seed=1,
              stat_fun=stat_fun,
              out_type="mask",
              buffer_size=None,
          )
  
          (
              T_obs_neg,
              _,
              cluster_p_values_neg,
              _,
          ) = permutation_cluster_1samp_test(
              -condition1,
              n_permutations=100,
              tail=-1,
              threshold=-1.67,
              seed=1,
              stat_fun=stat_fun,
              buffer_size=None,
              out_type="mask",
          )
          assert_array_equal(T_obs_pos, -T_obs_neg)
          assert_array_equal(
              cluster_p_values_pos < 0.05, cluster_p_values_neg < 0.05
          )
  
          # test with 2 jobs and buffer_size enabled
          buffer_size = condition1.shape[1] // 10
          with _record_warnings():  # sometimes "independently"
              (
                  T_obs_neg_buff,
                  _,
                  cluster_p_values_neg_buff,
                  _,
              ) = permutation_cluster_1samp_test(
                  -condition1,
                  n_permutations=100,
                  tail=-1,
                  out_type="mask",
                  threshold=-1.67,
                  seed=1,
                  n_jobs=2,
                  stat_fun=stat_fun,
                  buffer_size=buffer_size,
              )
  
          assert_array_equal(T_obs_neg, T_obs_neg_buff)
          assert_array_equal(
              cluster_p_values_neg, cluster_p_values_neg_buff
          )
  
          # Bad stat_fun
          with pytest.raises(TypeError, match="must be .* ndarray"):
              permutation_cluster_1samp_test(
                  condition1,
                  threshold=1,
                  stat_fun=lambda x: None,
                  out_type="mask",
              )
          with pytest.raises(ValueError, match="not compatible"):
              permutation_cluster_1samp_test(
                  condition1,
                  threshold=1,
                  stat_fun=lambda x: stat_fun(x)[:-1],
                  out_type="mask",
              )
  
imports: import os
  from functools import partial
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import linalg, sparse, stats
  from mne import MixedSourceEstimate, SourceEstimate, SourceSpaces, VolSourceEstimate
  from mne.stats import combine_adjacency, ttest_ind_no_p
  from mne.stats.cluster_level import f_oneway, permutation_cluster_1samp_test, permutation_cluster_test, spatio_temporal_cluster_1samp_test, spatio_temporal_cluster_test, summarize_clusters_stc, ttest_1samp_no_p
  from mne.utils import _record_warnings, catch_logging
label_desc: Use image node_id 7 for calling a global function with example usage: test_cluster_permutation_t_test(numba_conditional, stat_fun) without return types