code: def mcnemar(table, exact=True, correction=True):
      """
      McNemar test of homogeneity.
  
      Parameters
      ----------
      table : array_like
          A square contingency table.
      exact : bool
          If exact is true, then the binomial distribution will be used.
          If exact is false, then the chisquare distribution will be
          used, which is the approximation to the distribution of the
          test statistic for large sample sizes.
      correction : bool
          If true, then a continuity correction is used for the chisquare
          distribution (if exact is false.)
  
      Returns
      -------
      A bunch with attributes:
  
      statistic : float or int, array
          The test statistic is the chisquare statistic if exact is
          false. If the exact binomial distribution is used, then this
          contains the min(n1, n2), where n1, n2 are cases that are zero
          in one sample but one in the other sample.
      pvalue : float or array
          p-value of the null hypothesis of equal marginal distributions.
  
      Notes
      -----
      This is a special case of Cochran's Q test, and of the homogeneity
      test. The results when the chisquare distribution is used are
      identical, except for continuity correction.
      """
  
      table = _make_df_square(table)
      table = np.asarray(table, dtype=np.float64)
      n1, n2 = table[0, 1], table[1, 0]
  
      if exact:
          statistic = np.minimum(n1, n2)
          # binom is symmetric with p=0.5
          # SciPy 1.7+ requires int arguments
          int_sum = int(n1 + n2)
          if int_sum != (n1 + n2):
              raise ValueError(
                  "exact can only be used with tables containing integers."
              )
          pvalue = stats.binom.cdf(statistic, int_sum, 0.5) * 2
          pvalue = np.minimum(pvalue, 1)  # limit to 1 if n1==n2
      else:
          corr = int(correction)  # convert bool to 0 or 1
          statistic = (np.abs(n1 - n2) - corr) ** 2 / (1.0 * (n1 + n2))
          df = 1
          pvalue = stats.chi2.sf(statistic, df)
  
      b = _Bunch()
      b.statistic = statistic
      b.pvalue = pvalue
      return b
  
imports: import warnings
  import numpy
  import pandas
  from scipy import stats
  from statsmodels import iolib
  from statsmodels.tools import sm_exceptions
  from statsmodels.tools.decorators import cache_readonly
label_desc: Use image node_id 2 for calling a global function with example usage: mcnemar(table, exact, correction) and returns: b