code: def test_permutation(permutation_params):
      n_features, n_instances, n_permutations, mult = permutation_params
      xshape, yshape = (n_instances[0], n_features), (
          n_instances[1],
          n_features,
      )
      np.random.seed(0)
      x = np.random.random(xshape).astype(np.float32)
      y = np.random.random(yshape).astype(np.float32) * mult
  
      def metric_fn(x, y):
          return mmd2(
              x, y, kernel=GaussianRBF(sigma=tf.ones(1))
          ).numpy()
  
      p_val, dist, dist_permutations = permutation_test(
          x, y, n_permutations=n_permutations, metric=metric_fn
      )
      if mult == 1:
          assert p_val > 0.2
      elif mult > 1:
          assert p_val <= 0.2
      assert (
          np.where(dist_permutations >= dist)[0].shape[0]
          / n_permutations
          == p_val
      )
  
file_path: alibi-detect/alibi_detect/utils/tests/test_statstest.py
imports: from itertools import product
  import numpy
  import pytest
  import tensorflow
  from alibi_detect.utils.tensorflow import GaussianRBF, mmd2
  from alibi_detect.utils.statstest import fdr, permutation_test
label_desc: Use image node_id 4 for calling a global function with example usage: test_permutation(permutation_params) and returns: mmd2