code: def test_t_test_execution(setup):
      if parse_version(scipy.__version__) >= parse_version("1.6.0"):
          alternatives = ["less", "greater", "two-sided"]
  
          mt_from_stats = lambda a, b, alternative=None, equal_var=True: ttest_ind_from_stats(
              a.mean(),
              a.std(),
              a.shape[0],
              b.mean(),
              b.std(),
              b.shape[0],
              alternative=alternative,
              equal_var=equal_var,
          )
          sp_from_stats = lambda a, b, alternative=None, equal_var=True: sp_ttest_ind_from_stats(
              a.mean(),
              a.std(),
              a.shape[0],
              b.mean(),
              b.std(),
              b.shape[0],
              alternative=alternative,
              equal_var=equal_var,
          )
      else:
          alternatives = ["two-sided"]
  
          mt_from_stats = (
              lambda a, b, equal_var=True: ttest_ind_from_stats(
                  a.mean(),
                  a.std(),
                  a.shape[0],
                  b.mean(),
                  b.std(),
                  b.shape[0],
                  equal_var=equal_var,
              )
          )
          sp_from_stats = (
              lambda a, b, equal_var=True: sp_ttest_ind_from_stats(
                  a.mean(),
                  a.std(),
                  a.shape[0],
                  b.mean(),
                  b.std(),
                  b.shape[0],
                  equal_var=equal_var,
              )
          )
  
      funcs = [
          (ttest_rel, sp_ttest_rel),
          (
              functools.partial(ttest_ind, equal_var=True),
              functools.partial(sp_ttest_ind, equal_var=True),
          ),
          (
              functools.partial(ttest_ind, equal_var=False),
              functools.partial(sp_ttest_ind, equal_var=False),
          ),
          (
              functools.partial(mt_from_stats, equal_var=True),
              functools.partial(sp_from_stats, equal_var=True),
          ),
          (
              functools.partial(mt_from_stats, equal_var=False),
              functools.partial(sp_from_stats, equal_var=False),
          ),
      ]
  
      fa_raw = np.array([16, 18, 16, 14, 12, 12])
      fb_raw = np.array([16, 16, 16, 16, 16, 8])
  
      fa = tensor(fa_raw, chunk_size=4)
      fb = tensor(fb_raw, chunk_size=4)
  
      for mt_func, sp_func in funcs:
          if parse_version(scipy.__version__) >= parse_version("1.6.0"):
              with pytest.raises(ValueError):
                  mt_func(fa, fb, alternative="illegal-alternative")
  
          for alt in alternatives:
              if parse_version(scipy.__version__) >= parse_version(
                  "1.6.0"
              ):
                  r = mt_func(fa, fb, alternative=alt)
              else:
                  r = mt_func(fa, fb)
              result = r.execute().fetch()
  
              if parse_version(scipy.__version__) >= parse_version(
                  "1.6.0"
              ):
                  expected = sp_func(fa_raw, fb_raw, alternative=alt)
              else:
                  expected = sp_func(fa_raw, fb_raw)
              np.testing.assert_almost_equal(expected[0], result[0])
              np.testing.assert_almost_equal(expected[1], result[1])
  
      # second param size must be 1 for ttest_1samp
      fb_raw = np.array([16])
      fb = tensor(fb_raw)
      for alt in alternatives:
          if parse_version(scipy.__version__) >= parse_version("1.6.0"):
              r = ttest_1samp(fa, fb, alternative=alt)
          else:
              r = ttest_1samp(fa, fb)
          result = r.execute().fetch()
  
          if parse_version(scipy.__version__) >= parse_version("1.6.0"):
              expected = sp_ttest_1samp(fa_raw, fb_raw, alternative=alt)
          else:
              expected = sp_ttest_1samp(fa_raw, fb_raw)
          np.testing.assert_almost_equal(expected[0], result[0])
          np.testing.assert_almost_equal(expected[1], result[1])
  
file_path: mars/mars/tensor/stats/tests/test_stats_execution.py
imports: import functools
  import numpy
  import pytest
  import scipy
  from scipy.stats import entropy, power_divergence, chisquare, ks_1samp, ks_2samp, norm, ttest_rel, ttest_ind, ttest_ind_from_stats, ttest_1samp, rankdata
  from ....lib.version import parse
  from ...None import tensor
  from ..None import entropy, power_divergence, chisquare, ttest_ind, ttest_rel, ttest_1samp, ttest_ind_from_stats, ks_1samp, ks_2samp, rankdata
label_desc: Use image node_id 4 for calling a global function with example usage: test_t_test_execution(setup) without return types