docstr: Set self.propensity and self.propensity_models.
  
  It trains propensity models for all treatment groups, save them in self.propensity_models, and
  save propensity scores in self.propensity in dictionaries with treatment groups as keys.
  
  It will use self.model_p if available to train propensity models. Otherwise, it will use a default
  PropensityModel (i.e. ElasticNetPropensityModel).
  
  Args:
      X (np.matrix or np.array or pd.Dataframe): a feature matrix
      treatment (np.array or pd.Series): a treatment vector
      y (np.array or pd.Series): an outcome vector
docstr_tok: ["Set","self.propensity","and","self.propensity_models",".","It","trains","propensity","models","for","all","treatment","groups",",","save","them","in","self.propensity_models",",","and","save","propensity","scores","in","self.propensity","in","dictionaries","with","treatment","groups","as","keys",".","It","will","use","self.model_p","if","available","to","train","propensity","models",".","Otherwise",",","it","will","use","a","default","PropensityModel","(","i.e",".","ElasticNetPropensityModel",")",".","Args",":","X","(","np.matrix","or","np.array","or","pd.Dataframe",")",":","a","feature","matrix","treatment","(","np.array","or","pd.Series",")",":","a","treatment","vector","y","(","np.array","or","pd.Series",")",":","an","outcome","vector"]
code: def _set_propensity_models(self, X, treatment, y):
      """Set self.propensity and self.propensity_models.
  
      It trains propensity models for all treatment groups, save them in self.propensity_models, and
      save propensity scores in self.propensity in dictionaries with treatment groups as keys.
  
      It will use self.model_p if available to train propensity models. Otherwise, it will use a default
      PropensityModel (i.e. ElasticNetPropensityModel).
  
      Args:
          X (np.matrix or np.array or pd.Dataframe): a feature matrix
          treatment (np.array or pd.Series): a treatment vector
          y (np.array or pd.Series): an outcome vector
      """
      logger.info("Generating propensity score")
      p = dict()
      p_model = dict()
      for group in self.t_groups:
          mask = (treatment == group) | (treatment == self.control_name)
          treatment_filt = treatment[mask]
          X_filt = X[mask]
          w_filt = (treatment_filt == group).astype(int)
          w = (treatment == group).astype(int)
          propensity_model = (
              self.model_p if hasattr(self, "model_p") else None
          )
          p[group], p_model[group] = compute_propensity_score(
              X=X_filt,
              treatment=w_filt,
              p_model=propensity_model,
              X_pred=X,
              treatment_pred=w,
          )
      self.propensity_model = p_model
      self.propensity = p
  
imports: from abc import ABCMeta, abstractclassmethod
  import logging
  import numpy
  import pandas
  from causalml.inference.meta.explainer import Explainer
  from causalml.inference.meta.utils import check_p_conditions, convert_pd_to_np
  from causalml.propensity import compute_propensity_score
label_desc: Use image node_id 7 for calling the BaseLearner obj's underlying member method code with example usage: obj._set_propensity_models(X, treatment, y) without return types