code: def _get_wmean_wvar(X, weight):
      """
      Calculate the weighted mean of a variable given an arbitrary
      sample weight. Formulas from:
  
      Austin, Peter C., and Elizabeth A. Stuart. 2015. Moving towards Best
      Practice When Using Inverse Probability of Treatment Weighting (IPTW)
      Using the Propensity Score to Estimate Causal Treatment Effects in
      Observational Studies.
      Statistics in Medicine 34 (28): 3661 79. https://doi.org/10.1002/sim.6607.
      """
      weighted_mean = np.sum(weight * X) / np.sum(weight)
      weighted_var = (
          np.sum(weight)
          / (np.power(np.sum(weight), 2) - np.sum(np.power(weight, 2)))
      ) * (np.sum(weight * np.power((X - weighted_mean), 2)))
  
      return [weighted_mean, weighted_var]
  
imports: from matplotlib import pyplot
  import logging
  import numpy
  import pandas
  import seaborn
  from lightgbm import LGBMRegressor
  from ..inference.meta.tmle import TMLELearner
label_desc: Use image node_id 20 for calling a global function with example usage: _get_wmean_wvar(X, weight) and returns: list