code: def state_propensity_score(
      data, covariates, treatments, variable_types=None
  ):
      if len(set(covariates).intersection(treatments)) != 0:
          raise Exception(
              "Can't control for causal states. Remove treatment from covariates."
          )
      log_propensities = {}
      for i, treatment in enumerate(treatments):
          if variable_types[treatment] in ["b"]:
              log_propensities[treatment] = np.log(
                  binary_treatment_model(
                      data.copy(),
                      covariates + treatments[i + 1 :],
                      treatment,
                      variable_types,
                  )
              )
          elif variable_types[treatment] in ["o", "u", "d"]:
              log_propensities[treatment] = np.log(
                  categorical_treatment_model(
                      data.copy(),
                      covariates + treatments[i + 1 :],
                      treatment,
                      variable_types,
                  )
              )
          elif variable_types[treatment] in ["c"]:
              log_propensities[treatment] = np.log(
                  continuous_treatment_model(
                      data.copy(),
                      covariates + treatments[i + 1 :],
                      treatment,
                      variable_types,
                  )
              )
          else:
              raise Exception(
                  "Variable type {} for variable {} is not a recognized format type.".format(
                      variable_types[treatment], treatment
                  )
              )
      scores = np.zeros(len(data))
      for treatment in treatments:
          scores += log_propensities[treatment]
      return np.exp(scores)
  
file_path: dowhy/dowhy/utils/propensity_score.py
imports: import numpy
  import pandas
  from pandas import get_dummies
  from sklearn.linear_model import LogisticRegression
  from sklearn.preprocessing import LabelEncoder
  from statsmodels.nonparametric.kernel_density import EstimatorSettings, KDEMultivariateConditional
label_desc: Use image node_id 2 for calling a global function with example usage: state_propensity_score(data, covariates, treatments, variable_types) and returns: np