class_docstr: A mixin providing generic (not family-specific) methods for
  variational Bayes mean field fitting.
class_docstr_tok: ["A","mixin","providing","generic","(","not","family-specific",")","methods","for","variational","Bayes","mean","field","fitting","."]
code: def _elbo_grad_common(
      self, fep_mean, fep_sd, vcp_mean, vcp_sd, vc_mean, vc_sd
  ):
      # p(vc | vcp) contributions
      m = vcp_mean[self.ident]
      s = vcp_sd[self.ident]
      u = vc_mean**2 + vc_sd**2
      ve = np.exp(2 * (s**2 - m))
      dm = u * ve - 1
      ds = -2 * u * ve * s
      vcp_mean_grad = np.bincount(self.ident, weights=dm)
      vcp_sd_grad = np.bincount(self.ident, weights=ds)
  
      vc_mean_grad = -vc_mean.copy() * ve
      vc_sd_grad = -vc_sd.copy() * ve
  
      # p(vcp) contributions
      vcp_mean_grad -= vcp_mean / self.vcp_p**2
      vcp_sd_grad -= vcp_sd / self.vcp_p**2
  
      # p(b) contributions
      fep_mean_grad = -fep_mean.copy() / self.fe_p**2
      fep_sd_grad = -fep_sd.copy() / self.fe_p**2
  
      return (
          fep_mean_grad,
          fep_sd_grad,
          vcp_mean_grad,
          vcp_sd_grad,
          vc_mean_grad,
          vc_sd_grad,
      )
  
imports: import numpy
  from scipy.optimize import minimize
  from scipy import sparse
  import statsmodels.base.model
  from statsmodels.iolib import summary2
  from statsmodels.genmod import families
  import pandas
  import warnings
  import patsy
label_desc: Use image node_id 6 for calling the _VariationalBayesMixedGLM obj's underlying member method code with example usage: obj._elbo_grad_common(fep_mean, fep_sd, vcp_mean, vcp_sd, vc_mean, vc_sd) and returns: fep_mean_grad,  fep_sd_grad,  vcp_mean_grad,  vcp_sd_grad,  vc_mean_grad,  vc_sd_grad