code: def cov_hc2(results):
      """
      See statsmodels.RegressionResults
      """
  
      # probably could be optimized
      h = np.diag(
          np.dot(
              results.model.exog,
              np.dot(
                  results.normalized_cov_params, results.model.exog.T
              ),
          )
      )
      het_scale = results.resid**2 / (1 - h)
      cov_hc2_ = _HCCM(results, het_scale)
      return cov_hc2_
  
imports: import numpy
  from statsmodels.tools.grouputils import combine_indices, group_sums
  from statsmodels.stats.moment_helpers import se_cov
label_desc: Use image node_id 4 for calling a global function with example usage: cov_hc2(results) and returns: cov_hc2_