code: def het_breuschpagan(resid, exog_het, robust=True):
      r"""
      Breusch-Pagan Lagrange Multiplier test for heteroscedasticity
  
      The tests the hypothesis that the residual variance does not depend on
      the variables in x in the form
  
      .. :math: \sigma_i = \sigma * f(\alpha_0 + \alpha z_i)
  
      Homoscedasticity implies that :math:`\alpha=0`.
  
      Parameters
      ----------
      resid : array_like
          For the Breusch-Pagan test, this should be the residual of a
          regression. If an array is given in exog, then the residuals are
          calculated by the an OLS regression or resid on exog. In this case
          resid should contain the dependent variable. Exog can be the same as x.
      exog_het : array_like
          This contains variables suspected of being related to
          heteroscedasticity in resid.
      robust : bool, default True
          Flag indicating whether to use the Koenker version of the
          test (default) which assumes independent and identically distributed
          error terms, or the original Breusch-Pagan version which assumes
          residuals are normally distributed.
  
      Returns
      -------
      lm : float
          lagrange multiplier statistic
      lm_pvalue : float
          p-value of lagrange multiplier test
      fvalue : float
          f-statistic of the hypothesis that the error variance does not depend
          on x
      f_pvalue : float
          p-value for the f-statistic
  
      Notes
      -----
      Assumes x contains constant (for counting dof and calculation of R^2).
      In the general description of LM test, Greene mentions that this test
      exaggerates the significance of results in small or moderately large
      samples. In this case the F-statistic is preferable.
  
      **Verification**
  
      Chisquare test statistic is exactly (<1e-13) the same result as bptest
      in R-stats with defaults (studentize=True).
  
      **Implementation**
  
      This is calculated using the generic formula for LM test using $R^2$
      (Greene, section 17.6) and not with the explicit formula
      (Greene, section 11.4.3), unless `robust` is set to False.
      The degrees of freedom for the p-value assume x is full rank.
  
      References
      ----------
      .. [1] Greene, W. H. Econometric Analysis. New Jersey. Prentice Hall;
         5th edition. (2002).
      .. [2]  Breusch, T. S.; Pagan, A. R. (1979). "A Simple Test for
         Heteroskedasticity and Random Coefficient Variation". Econometrica.
         47 (5): 1287–1294.
      .. [3] Koenker, R. (1981). "A note on studentizing a test for
         heteroskedasticity". Journal of Econometrics 17 (1): 107–112.
      """
      x = array_like(exog_het, "exog_het", ndim=2)
      _check_het_test(x, "The Breusch-Pagan")
      y = array_like(resid, "resid", ndim=1) ** 2
      if not robust:
          y = y / np.mean(y)
      nobs, nvars = x.shape
      resols = OLS(y, x).fit()
      fval = resols.fvalue
      fpval = resols.f_pvalue
      lm = nobs * resols.rsquared if robust else resols.ess / 2
      # Note: degrees of freedom for LM test is nvars minus constant
      return lm, stats.chi2.sf(lm, nvars - 1), fval, fpval
  
imports: from statsmodels.compat.pandas import deprecate_kwarg
  from collections.abc import Iterable
  import numpy
  import pandas
  from scipy import stats
  from statsmodels.regression.linear_model import OLS, RegressionResultsWrapper
  from statsmodels.stats._adnorm import anderson_statistic, normal_ad
  from statsmodels.stats._lilliefors import kstest_exponential, kstest_fit, kstest_normal, lilliefors
  from statsmodels.tools.validation import array_like, bool_like, dict_like, float_like, int_like, string_like
  from statsmodels.tsa.tsatools import lagmat
label_desc: Use image node_id 11 for calling a global function with example usage: het_breuschpagan(resid, exog_het, robust) and returns: lm,  stats,  fval,  fpval