class_docstr: Base class for Gaussian Likelihoods, supporting general heteroskedastic noise models.
class_docstr_tok: ["Base","class","for","Gaussian","Likelihoods",",","supporting","general","heteroskedastic","noise","models","."]
code: def log_marginal(
      self,
      observations: Tensor,
      function_dist: MultivariateNormal,
      *params: Any,
      **kwargs: Any,
  ) -> Tensor:
      marginal = self.marginal(function_dist, *params, **kwargs)
  
      # Handle NaN values if enabled
      nan_policy = settings.observation_nan_policy.value()
      if nan_policy == "mask":
          observed = settings.observation_nan_policy._get_observed(
              observations, marginal.event_shape
          )
          marginal = MultivariateNormal(
              mean=marginal.mean[..., observed],
              covariance_matrix=MaskedLinearOperator(
                  marginal.lazy_covariance_matrix,
                  observed.reshape(-1),
                  observed.reshape(-1),
              ),
          )
          observations = observations[..., observed]
      elif nan_policy == "fill":
          missing = torch.isnan(observations)
          observations = settings.observation_nan_policy._fill_tensor(
              observations
          )
  
      # We're making everything conditionally independent
      indep_dist = base_distributions.Normal(
          marginal.mean, marginal.variance.clamp_min(1e-8).sqrt()
      )
      res = indep_dist.log_prob(observations)
  
      if nan_policy == "fill":
          res = res * ~missing
  
      # Do appropriate summation for multitask Gaussian likelihoods
      num_event_dim = len(marginal.event_shape)
      if num_event_dim > 1:
          res = res.sum(list(range(-1, -num_event_dim, -1)))
      return res
  
imports: import math
  import warnings
  from copy import deepcopy
  from typing import Any, Optional, Tuple, Union
  import torch
  from linear_operator.operators import LinearOperator, MaskedLinearOperator, ZeroLinearOperator
  from torch import Tensor
  from torch.distributions import Distribution, Normal
  from ..None import settings
  from ..constraints import Interval
  from ..distributions import base_distributions, MultivariateNormal
  from ..priors import Prior
  from ..utils.warnings import GPInputWarning
  from .likelihood import Likelihood
  from .noise_models import FixedGaussianNoise, HomoskedasticNoise, Noise
label_desc: Use image node_id 5 for calling the _GaussianLikelihoodBase obj's underlying member method code with example usage: obj.log_marginal(observations, function_dist) and returns: res