code: def ate_ipw(endog, tind, prob, weighted=True, probt=None):
      """average treatment effect based on basic inverse propensity weighting."""
      w1 = tind / prob
      w0 = (1.0 - tind) / (1.0 - prob)
  
      if probt is not None:
          w1 *= probt
          w0 *= probt
  
      if weighted:
          w0 /= w0.mean()
          w1 /= w1.mean()
  
      wdiff = w1 - w0
  
      return (
          (endog * wdiff).mean(),
          (endog * w0).mean(),
          (endog * w1).mean(),
      )
  
imports: import numpy
  from statsmodels.compat.pandas import Substitution
  from scipy.linalg import block_diag
  from statsmodels.regression.linear_model import WLS
  from statsmodels.sandbox.regression.gmm import GMM
  from statsmodels.stats.contrast import ContrastResults
  from statsmodels.tools.docstring import indent
label_desc: Use image node_id 6 for calling a global function with example usage: ate_ipw(endog, tind, prob, weighted, probt) and returns: unknown,  unknown,  unknown