code: def cramervonmises_2samp(x, y, method="auto"):
      """Perform the two-sample Cramér-von Mises test for goodness of fit.
  
      This is the two-sample version of the Cramér-von Mises test ([1]_):
      for two independent samples :math:`X_1, ..., X_n` and
      :math:`Y_1, ..., Y_m`, the null hypothesis is that the samples
      come from the same (unspecified) continuous distribution.
  
      Parameters
      ----------
      x : array_like
          A 1-D array of observed values of the random variables :math:`X_i`.
      y : array_like
          A 1-D array of observed values of the random variables :math:`Y_i`.
      method : {'auto', 'asymptotic', 'exact'}, optional
          The method used to compute the p-value, see Notes for details.
          The default is 'auto'.
  
      Returns
      -------
      res : object with attributes
          statistic : float
              Cramér-von Mises statistic.
          pvalue : float
              The p-value.
  
      See Also
      --------
      cramervonmises, anderson_ksamp, epps_singleton_2samp, ks_2samp
  
      Notes
      -----
      .. versionadded:: 1.7.0
  
      The statistic is computed according to equation 9 in [2]_. The
      calculation of the p-value depends on the keyword `method`:
  
      - ``asymptotic``: The p-value is approximated by using the limiting
        distribution of the test statistic.
      - ``exact``: The exact p-value is computed by enumerating all
        possible combinations of the test statistic, see [2]_.
  
      If ``method='auto'``, the exact approach is used
      if both samples contain equal to or less than 20 observations,
      otherwise the asymptotic distribution is used.
  
      If the underlying distribution is not continuous, the p-value is likely to
      be conservative (Section 6.2 in [3]_). When ranking the data to compute
      the test statistic, midranks are used if there are ties.
  
      References
      ----------
      .. [1] https://en.wikipedia.org/wiki/Cramer-von_Mises_criterion
      .. [2] Anderson, T.W. (1962). On the distribution of the two-sample
             Cramer-von-Mises criterion. The Annals of Mathematical
             Statistics, pp. 1148-1159.
      .. [3] Conover, W.J., Practical Nonparametric Statistics, 1971.
  
      Examples
      --------
  
      Suppose we wish to test whether two samples generated by
      ``scipy.stats.norm.rvs`` have the same distribution. We choose a
      significance level of alpha=0.05.
  
      >>> import numpy as np
      >>> from scipy import stats
      >>> rng = np.random.default_rng()
      >>> x = stats.norm.rvs(size=100, random_state=rng)
      >>> y = stats.norm.rvs(size=70, random_state=rng)
      >>> res = stats.cramervonmises_2samp(x, y)
      >>> res.statistic, res.pvalue
      (0.29376470588235293, 0.1412873014573014)
  
      The p-value exceeds our chosen significance level, so we do not
      reject the null hypothesis that the observed samples are drawn from the
      same distribution.
  
      For small sample sizes, one can compute the exact p-values:
  
      >>> x = stats.norm.rvs(size=7, random_state=rng)
      >>> y = stats.t.rvs(df=2, size=6, random_state=rng)
      >>> res = stats.cramervonmises_2samp(x, y, method='exact')
      >>> res.statistic, res.pvalue
      (0.197802197802198, 0.31643356643356646)
  
      The p-value based on the asymptotic distribution is a good approximation
      even though the sample size is small.
  
      >>> res = stats.cramervonmises_2samp(x, y, method='asymptotic')
      >>> res.statistic, res.pvalue
      (0.197802197802198, 0.2966041181527128)
  
      Independent of the method, one would not reject the null hypothesis at the
      chosen significance level in this example.
  
      """
      xa = np.sort(np.asarray(x))
      ya = np.sort(np.asarray(y))
  
      if xa.size <= 1 or ya.size <= 1:
          raise ValueError(
              "x and y must contain at least two observations."
          )
      if method not in ["auto", "exact", "asymptotic"]:
          raise ValueError(
              "method must be either auto, exact or asymptotic."
          )
  
      nx = len(xa)
      ny = len(ya)
  
      if method == "auto":
          if max(nx, ny) > 20:
              method = "asymptotic"
          else:
              method = "exact"
  
      # get ranks of x and y in the pooled sample
      z = np.concatenate([xa, ya])
      # in case of ties, use midrank (see [1])
      r = scipy.stats.rankdata(z, method="average")
      rx = r[:nx]
      ry = r[nx:]
  
      # compute U (eq. 10 in [2])
      u = nx * np.sum((rx - np.arange(1, nx + 1)) ** 2)
      u += ny * np.sum((ry - np.arange(1, ny + 1)) ** 2)
  
      # compute T (eq. 9 in [2])
      k, N = nx * ny, nx + ny
      t = u / (k * N) - (4 * k - 1) / (6 * N)
  
      if method == "exact":
          p = _pval_cvm_2samp_exact(u, nx, ny)
      else:
          # compute expected value and variance of T (eq. 11 and 14 in [2])
          et = (1 + 1 / N) / 6
          vt = (N + 1) * (4 * k * N - 3 * (nx**2 + ny**2) - 2 * k)
          vt = vt / (45 * N**2 * 4 * k)
  
          # computed the normalized statistic (eq. 15 in [2])
          tn = 1 / 6 + (t - et) / np.sqrt(45 * vt)
  
          # approximate distribution of tn with limiting distribution
          # of the one-sample test statistic
          # if tn < 0.003, the _cdf_cvm_inf(tn) < 1.28*1e-18, return 1.0 directly
          if tn < 0.003:
              p = 1.0
          else:
              p = max(0, 1.0 - _cdf_cvm_inf(tn))
  
      return CramerVonMisesResult(statistic=t, pvalue=p)
  
imports: from collections import namedtuple
  from dataclasses import dataclass
  from math import comb
  import numpy
  import warnings
  from itertools import combinations
  import scipy.stats
  from scipy.optimize import shgo
  from .None import distributions
  from ._common import ConfidenceInterval
  from ._continuous_distns import chi2, norm
  from scipy.special import gamma, kv, gammaln
  from scipy.fft import ifft
  from ._stats_pythran import _a_ij_Aij_Dij2
  from ._stats_pythran import _concordant_pairs, _discordant_pairs
  from ._axis_nan_policy import _axis_nan_policy_factory
  from scipy.stats import _stats_py
label_desc: Use image node_id 20 for calling a global function with example usage: cramervonmises_2samp(x, y, method) and returns: CramerVonMisesResult