code: def two_sample_test(sample1, sample2, n_sims=1000, alpha=0.05):
      """Calculate test whose null hypothesis is that two sets of samples were drawn from
      the same distribution.
  
      Largely taken from https://torchdrift.org/notebooks/note_on_mmd.html
      """
      # build function to calculate mmd
      calc_mmd = build_mmd_func(sample1, sample2)
  
      # simulate test statistic under null hypothesis
      X = np.concatenate((sample1, sample2), axis=0)
      half_N = int(X.shape[0] // 2)
      ix = np.arange(half_N * 2)
  
      h0 = []
      for i in range(n_sims):
          np.random.shuffle(ix)
          X = X[ix, :]
          h0.append(calc_mmd(X[:half_N, :], X[half_N:, :]))
      h0 = np.asarray(h0)
      critical_value = np.percentile(h0, 100 * (1 - alpha))
      mmd = calc_mmd(sample1, sample2)
      return h0, mmd, critical_value, mmd > critical_value
  
imports: import arviz
  import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  from scipy.spatial import distance
  import pymc
label_desc: Use image node_id 2 for calling a global function with example usage: two_sample_test(sample1, sample2, n_sims, alpha) and returns: h0,  mmd,  critical_value,  unknown