code: def sensitivity_non_parametric_partial_r2(
      estimate: CausalEstimate,
      kappa_t: Optional[Union[float, np.ndarray]] = None,
      kappa_y: Optional[Union[float, np.ndarray]] = None,
      frac_strength_treatment: float = 1.0,
      frac_strength_outcome: float = 1.0,
      benchmark_common_causes: Optional[List[str]] = None,
      plot_estimate: bool = True,
      alpha_s_estimator_list: Optional[List] = None,
      alpha_s_estimator_param_list: Optional[List[Dict]] = None,
      g_s_estimator_list: Optional[List] = None,
      g_s_estimator_param_list: Optional[List[Dict]] = None,
      plugin_reisz: bool = False,
  ):  # -> Union[PartialLinearSensitivityAnalyzer, NonParametricSensitivityAnalyzer]
      """Add an unobserved confounder for refutation using Non-parametric partial R2 methond (Sensitivity Analysis for non-parametric models).
  
      :param estimate: CausalEstimate: Estimate to run the refutation
      :param kappa_t: float, numpy.ndarray: Partial R2 of the unobserved confounder wrt the treatment conditioned on the observed confounders. Only in the case of general non-parametric-partial-R2, it is the fraction of variance in the reisz representer that is explained by the unobserved confounder; specifically  (1-r), where r is the ratio of variance of reisz representer, alpha^2, based on observed confounders and that based on all confounders.
      :param kappa_y: float, numpy.ndarray: Partial R2 of the unobserved confounder wrt the outcome conditioned on the treatment and observed confounders.
      :param frac_strength_treatment: float: This parameter decides the effect strength of the simulated confounder as a fraction of the effect strength of observed confounders on treatment. Defaults to 1.
      :param frac_strength_outcome: float: This parameter decides the effect strength of the simulated confounder as a fraction of the effect strength of observed confounders on outcome. Defaults to 1.
      :param benchmark_common_causes: names of variables for bounding strength of confounders. (relevant only for partial-r2 based simulation methods)
      :param plot_estimate: Generate contour plot for estimate while performing sensitivity analysis. (default = True).
                              (relevant only for partial-r2 based simulation methods)
      :param alpha_s_estimator_list: list of estimator objects for estimating alpha_s. These objects should have fit() and predict() methods (relevant only for non-parametric-partial-R2 method)
      :param alpha_s_estimator_param_list: list of dictionaries with parameters for finding alpha_s. (relevant only for non-parametric-partial-R2 simulation method)
      :param g_s_estimator_list: list of estimator objects for finding g_s. These objects should have fit() and predict() functions implemented. (relevant only for non-parametric-partial-R2 simulation method)
      :param g_s_estimator_param_list: list of dictionaries with parameters for tuning respective estimators in "g_s_estimator_list". The order of the dictionaries in the list should be consistent with the estimator objects order in "g_s_estimator_list". (relevant only for non-parametric-partial-R2 simulation method)
      :plugin_reisz: bool: Flag on whether to use the plugin estimator or the nonparametric estimator for reisz representer function (alpha_s).
      """
  
      import dowhy.causal_estimators.econml
      from dowhy.causal_refuters.non_parametric_sensitivity_analyzer import (
          NonParametricSensitivityAnalyzer,
      )
      from dowhy.causal_refuters.partial_linear_sensitivity_analyzer import (
          PartialLinearSensitivityAnalyzer,
      )
  
      # If the estimator used is LinearDML, partially linear sensitivity analysis will be automatically chosen
      if (
          isinstance(
              estimate.estimator, dowhy.causal_estimators.econml.Econml
          )
          and estimate.estimator.estimator.__class__.__name__
          == "LinearDML"
      ):
          analyzer = PartialLinearSensitivityAnalyzer(
              estimator=estimate._estimator_object,
              observed_common_causes=estimate.estimator._observed_common_causes,
              treatment=estimate._data[estimate._treatment_name],
              outcome=estimate._data[estimate._outcome_name[0]],
              alpha_s_estimator_param_list=alpha_s_estimator_param_list,
              g_s_estimator_list=g_s_estimator_list,
              g_s_estimator_param_list=g_s_estimator_param_list,
              effect_strength_treatment=kappa_t,
              effect_strength_outcome=kappa_y,
              benchmark_common_causes=benchmark_common_causes,
              frac_strength_treatment=frac_strength_treatment,
              frac_strength_outcome=frac_strength_outcome,
          )
          analyzer.check_sensitivity(plot=plot_estimate)
          return analyzer
  
      analyzer = NonParametricSensitivityAnalyzer(
          estimator=estimate.estimator,
          observed_common_causes=estimate.estimator._observed_common_causes,
          treatment=estimate._data[estimate._treatment_name],
          outcome=estimate._data[estimate._outcome_name[0]],
          alpha_s_estimator_list=alpha_s_estimator_list,
          alpha_s_estimator_param_list=alpha_s_estimator_param_list,
          g_s_estimator_list=g_s_estimator_list,
          g_s_estimator_param_list=g_s_estimator_param_list,
          effect_strength_treatment=kappa_t,
          effect_strength_outcome=kappa_y,
          benchmark_common_causes=benchmark_common_causes,
          frac_strength_treatment=frac_strength_treatment,
          frac_strength_outcome=frac_strength_outcome,
          theta_s=estimate.value,
          plugin_reisz=plugin_reisz,
      )
      analyzer.check_sensitivity(plot=plot_estimate)
      return analyzer
  
imports: import copy
  import logging
  import math
  from typing import Dict, List, Optional, Union
  import numpy
  import pandas
  import scipy.stats
  import statsmodels.api
  from sklearn.linear_model import LogisticRegression
  from sklearn.preprocessing import StandardScaler
  from tqdm.auto import tqdm
  from dowhy.causal_estimator import CausalEstimate
  from dowhy.causal_estimators.econml import Econml
  from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator
  from dowhy.causal_estimators.regression_estimator import RegressionEstimator
  from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand
  from dowhy.causal_refuter import CausalRefutation, CausalRefuter, choose_variables
  from dowhy.causal_refuters.evalue_sensitivity_analyzer import EValueSensitivityAnalyzer
  from dowhy.causal_refuters.linear_sensitivity_analyzer import LinearSensitivityAnalyzer
label_desc: Use image node_id 8 for calling a global function with example usage: sensitivity_non_parametric_partial_r2(estimate, kappa_t, kappa_y, frac_strength_treatment, frac_strength_outcome, benchmark_common_causes, plot_estimate, alpha_s_estimator_list, alpha_s_estimator_param_list, g_s_estimator_list, g_s_estimator_param_list, plugin_reisz) and returns: analyzer, analyzer