class_docstr: Implements Gauss-Hermite quadrature for integrating a function with respect to several 1D Gaussian distributions
  in batch mode. Within GPyTorch, this is useful primarily for computing expected log likelihoods for variational
  inference.
  
  This is implemented as a Module because Gauss-Hermite quadrature has a set of locations and weights that it
  should initialize one time, but that should obey parent calls to .cuda(), .double() etc.
class_docstr_tok: ["Implements","Gauss-Hermite","quadrature","for","integrating","a","function","with","respect","to","several","1D","Gaussian","distributions","in","batch","mode",".","Within","GPyTorch",",","this","is","useful","primarily","for","computing","expected","log","likelihoods","for","variational","inference",".","This","is","implemented","as","a","Module","because","Gauss-Hermite","quadrature","has","a","set","of","locations","and","weights","that","it","should","initialize","one","time",",","but","that","should","obey","parent","calls","to",".cuda","(",")",",",".double","(",")","etc","."]
docstr: Runs Gauss-Hermite quadrature on the callable func, integrating against the Gaussian distributions specified
  by gaussian_dists.
  
  Args:
      - func (callable): Function to integrate
      - gaussian_dists (Distribution): Either a MultivariateNormal whose covariance is assumed to be diagonal
          or a :obj:`torch.distributions.Normal`.
  Returns:
      - Result of integrating func against each univariate Gaussian in gaussian_dists.
docstr_tok: ["Runs","Gauss-Hermite","quadrature","on","the","callable","func",",","integrating","against","the","Gaussian","distributions","specified","by","gaussian_dists",".","Args",":","-","func","(","callable",")",":","Function","to","integrate","-","gaussian_dists","(","Distribution",")",":","Either","a","MultivariateNormal","whose","covariance","is","assumed","to","be","diagonal","or","a",":","obj",":","`","torch.distributions.Normal","`",".","Returns",":","-","Result","of","integrating","func","against","each","univariate","Gaussian","in","gaussian_dists","."]
code: def forward(self, func, gaussian_dists):
      """
      Runs Gauss-Hermite quadrature on the callable func, integrating against the Gaussian distributions specified
      by gaussian_dists.
  
      Args:
          - func (callable): Function to integrate
          - gaussian_dists (Distribution): Either a MultivariateNormal whose covariance is assumed to be diagonal
              or a :obj:`torch.distributions.Normal`.
      Returns:
          - Result of integrating func against each univariate Gaussian in gaussian_dists.
      """
      means = gaussian_dists.mean
      variances = gaussian_dists.variance
  
      locations = _pad_with_singletons(
          self.locations,
          num_singletons_before=0,
          num_singletons_after=means.dim(),
      )
  
      shifted_locs = torch.sqrt(2.0 * variances) * locations + means
      log_probs = func(shifted_locs)
      weights = _pad_with_singletons(
          self.weights,
          num_singletons_before=0,
          num_singletons_after=log_probs.dim() - 1,
      )
  
      res = (1 / math.sqrt(math.pi)) * (log_probs * weights)
      res = res.sum(tuple(range(self.locations.dim())))
  
      return res
  
file_path: gpytorch/gpytorch/utils/quadrature.py
imports: import math
  import numpy
  import torch
  from torch.nn import Module
  from ..None import settings
label_desc: Use image node_id 4 for calling the GaussHermiteQuadrature1D obj's underlying member method code with example usage: obj.forward(func, gaussian_dists) and returns: res