code: def confint_proportions_2indep(
      count1,
      nobs1,
      count2,
      nobs2,
      method=None,
      compare="diff",
      alpha=0.05,
      correction=True,
  ):
      """
      Confidence intervals for comparing two independent proportions.
  
      This assumes that we have two independent binomial samples.
  
      Parameters
      ----------
      count1, nobs1 : float
          Count and sample size for first sample.
      count2, nobs2 : float
          Count and sample size for the second sample.
      method : str
          Method for computing confidence interval. If method is None, then a
          default method is used. The default might change as more methods are
          added.
  
          diff:
           - 'wald',
           - 'agresti-caffo'
           - 'newcomb' (default)
           - 'score'
  
          ratio:
           - 'log'
           - 'log-adjusted' (default)
           - 'score'
  
          odds-ratio:
           - 'logit'
           - 'logit-adjusted' (default)
           - 'score'
  
      compare : string in ['diff', 'ratio' 'odds-ratio']
          If compare is diff, then the confidence interval is for diff = p1 - p2.
          If compare is ratio, then the confidence interval is for the risk ratio
          defined by ratio = p1 / p2.
          If compare is odds-ratio, then the confidence interval is for the
          odds-ratio defined by or = p1 / (1 - p1) / (p2 / (1 - p2).
      alpha : float
          Significance level for the confidence interval, default is 0.05.
          The nominal coverage probability is 1 - alpha.
  
      Returns
      -------
      low, upp
  
      See Also
      --------
      test_proportions_2indep
      tost_proportions_2indep
  
      Notes
      -----
      Status: experimental, API and defaults might still change.
          more ``methods`` will be added.
  
      References
      ----------
      .. [1] Fagerland, Morten W., Stian Lydersen, and Petter Laake. 2015.
         “Recommended Confidence Intervals for Two Independent Binomial
         Proportions.” Statistical Methods in Medical Research 24 (2): 224–54.
         https://doi.org/10.1177/0962280211415469.
      .. [2] Koopman, P. A. R. 1984. “Confidence Intervals for the Ratio of Two
         Binomial Proportions.” Biometrics 40 (2): 513–17.
         https://doi.org/10.2307/2531405.
      .. [3] Miettinen, Olli, and Markku Nurminen. "Comparative analysis of two
         rates." Statistics in medicine 4, no. 2 (1985): 213-226.
      .. [4] Newcombe, Robert G. 1998. “Interval Estimation for the Difference
         between Independent Proportions: Comparison of Eleven Methods.”
         Statistics in Medicine 17 (8): 873–90.
         https://doi.org/10.1002/(SICI)1097-0258(19980430)17:8<873::AID-
         SIM779>3.0.CO;2-I.
      .. [5] Newcombe, Robert G., and Markku M. Nurminen. 2011. “In Defence of
         Score Intervals for Proportions and Their Differences.” Communications
         in Statistics - Theory and Methods 40 (7): 1271–82.
         https://doi.org/10.1080/03610920903576580.
      """
      method_default = {
          "diff": "newcomb",
          "ratio": "log-adjusted",
          "odds-ratio": "logit-adjusted",
      }
      # normalize compare name
      if compare.lower() == "or":
          compare = "odds-ratio"
      if method is None:
          method = method_default[compare]
  
      method = method.lower()
      if method.startswith("agr"):
          method = "agresti-caffo"
  
      p1 = count1 / nobs1
      p2 = count2 / nobs2
      diff = p1 - p2
      addone = 1 if method == "agresti-caffo" else 0
  
      if compare == "diff":
          if method in ["wald", "agresti-caffo"]:
              count1_, nobs1_ = count1 + addone, nobs1 + 2 * addone
              count2_, nobs2_ = count2 + addone, nobs2 + 2 * addone
              p1_ = count1_ / nobs1_
              p2_ = count2_ / nobs2_
              diff_ = p1_ - p2_
              var = p1_ * (1 - p1_) / nobs1_ + p2_ * (1 - p2_) / nobs2_
              z = stats.norm.isf(alpha / 2)
              d_wald = z * np.sqrt(var)
              low = diff_ - d_wald
              upp = diff_ + d_wald
  
          elif method.startswith("newcomb"):
              low1, upp1 = proportion_confint(
                  count1, nobs1, method="wilson", alpha=alpha
              )
              low2, upp2 = proportion_confint(
                  count2, nobs2, method="wilson", alpha=alpha
              )
              d_low = np.sqrt((p1 - low1) ** 2 + (upp2 - p2) ** 2)
              d_upp = np.sqrt((p2 - low2) ** 2 + (upp1 - p1) ** 2)
              low = diff - d_low
              upp = diff + d_upp
  
          elif method == "score":
              low, upp = _score_confint_inversion(
                  count1,
                  nobs1,
                  count2,
                  nobs2,
                  compare=compare,
                  alpha=alpha,
                  correction=correction,
              )
  
          else:
              raise ValueError("method not recognized")
  
      elif compare == "ratio":
          # ratio = p1 / p2
          if method in ["log", "log-adjusted"]:
              addhalf = 0.5 if method == "log-adjusted" else 0
              count1_, nobs1_ = count1 + addhalf, nobs1 + addhalf
              count2_, nobs2_ = count2 + addhalf, nobs2 + addhalf
              p1_ = count1_ / nobs1_
              p2_ = count2_ / nobs2_
              ratio_ = p1_ / p2_
              var = (
                  (1 / count1_) - 1 / nobs1_ + 1 / count2_ - 1 / nobs2_
              )
              z = stats.norm.isf(alpha / 2)
              d_log = z * np.sqrt(var)
              low = np.exp(np.log(ratio_) - d_log)
              upp = np.exp(np.log(ratio_) + d_log)
  
          elif method == "score":
              res = _confint_riskratio_koopman(
                  count1,
                  nobs1,
                  count2,
                  nobs2,
                  alpha=alpha,
                  correction=correction,
              )
              low, upp = res.confint
  
          else:
              raise ValueError("method not recognized")
  
      elif compare == "odds-ratio":
          # odds_ratio = p1 / (1 - p1) / p2 * (1 - p2)
          if method in ["logit", "logit-adjusted", "logit-smoothed"]:
              if method in ["logit-smoothed"]:
                  adjusted = _shrink_prob(
                      count1,
                      nobs1,
                      count2,
                      nobs2,
                      shrink_factor=2,
                      return_corr=False,
                  )[0]
                  count1_, nobs1_, count2_, nobs2_ = adjusted
  
              else:
                  addhalf = 0.5 if method == "logit-adjusted" else 0
                  count1_, nobs1_ = (
                      count1 + addhalf,
                      nobs1 + 2 * addhalf,
                  )
                  count2_, nobs2_ = (
                      count2 + addhalf,
                      nobs2 + 2 * addhalf,
                  )
              p1_ = count1_ / nobs1_
              p2_ = count2_ / nobs2_
              odds_ratio_ = p1_ / (1 - p1_) / p2_ * (1 - p2_)
              var = (
                  1 / count1_
                  + 1 / (nobs1_ - count1_)
                  + 1 / count2_
                  + 1 / (nobs2_ - count2_)
              )
              z = stats.norm.isf(alpha / 2)
              d_log = z * np.sqrt(var)
              low = np.exp(np.log(odds_ratio_) - d_log)
              upp = np.exp(np.log(odds_ratio_) + d_log)
  
          elif method == "score":
              low, upp = _score_confint_inversion(
                  count1,
                  nobs1,
                  count2,
                  nobs2,
                  compare=compare,
                  alpha=alpha,
                  correction=correction,
              )
  
          else:
              raise ValueError("method not recognized")
  
      else:
          raise ValueError("compare not recognized")
  
      return low, upp
  
imports: from statsmodels.compat.python import lzip
  from typing import Callable
  import numpy
  import pandas
  from scipy import optimize, stats
  from statsmodels.stats.base import AllPairsResults, HolderTuple
  from statsmodels.stats.weightstats import _zstat_generic2
  from statsmodels.tools.sm_exceptions import HypothesisTestWarning
  from statsmodels.tools.testing import Holder
  from statsmodels.tools.validation import array_like
label_desc: Use image node_id 22 for calling a global function with example usage: confint_proportions_2indep(count1, nobs1, count2, nobs2, method, compare, alpha, correction) and returns: low,  upp