code: def mcnemar(ary, corrected=True, exact=False):
      """
      McNemar test for paired nominal data
  
      Parameters
      -----------
      ary : array-like, shape=[2, 2]
          2 x 2 contigency table (as returned by evaluate.mcnemar_table),
          where
          a: ary[0, 0]: # of samples that both models predicted correctly
          b: ary[0, 1]: # of samples that model 1 got right and model 2 got wrong
          c: ary[1, 0]: # of samples that model 2 got right and model 1 got wrong
          d: aryCell [1, 1]: # of samples that both models predicted incorrectly
      corrected : array-like, shape=[n_samples] (default: True)
          Uses Edward's continuity correction for chi-squared if `True`
      exact : bool, (default: False)
          If `True`, uses an exact binomial test comparing b to
          a binomial distribution with n = b + c and p = 0.5.
          It is highly recommended to use `exact=True` for sample sizes < 25
          since chi-squared is not well-approximated
          by the chi-squared distribution!
  
      Returns
      -----------
      chi2, p : float or None, float
          Returns the chi-squared value and the p-value;
          if `exact=True` (default: `False`), `chi2` is `None`
  
      Examples
      -----------
  
      For usage examples, please see
      https://rasbt.github.io/mlxtend/user_guide/evaluate/mcnemar/
  
      """
  
      if not ary.shape == (2, 2):
          raise ValueError("Input array must be a 2x2 array.")
  
      b = ary[0, 1]
      c = ary[1, 0]
      n = b + c
  
      if not exact:
          if corrected:
              chi2 = (abs(ary[0, 1] - ary[1, 0]) - 1.0) ** 2 / float(n)
          else:
              chi2 = (ary[0, 1] - ary[1, 0]) ** 2 / float(n)
          p = scipy.stats.distributions.chi2.sf(chi2, 1)
  
      else:
          chi2 = None
          p = min(
              scipy.stats.binom.cdf(min(b, c), b + c, 0.5) * 2.0, 1.0
          )
  
          # this is equivalent to the following code:
          #
          #    p = 0
          #    for i in range(max(b, c), b+c+1):
          #        p += scipy.special.binom(b+c, i) * 0.5**i * (1-0.5)**((b+c)-i)
          #    p = 2*p
  
      return chi2, p
  
imports: from itertools import combinations
  import numpy
  import scipy.stats
label_desc: Use image node_id 3 for calling a global function with example usage: mcnemar(ary, corrected, exact) and returns: chi2,  p