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 expected_log_prob(
      self,
      target: Tensor,
      input: MultivariateNormal,
      *params: Any,
      **kwargs: Any,
  ) -> Tensor:
      noise = self._shaped_noise_covar(
          input.mean.shape, *params, **kwargs
      ).diagonal(dim1=-1, dim2=-2)
      # Potentially reshape the noise to deal with the multitask case
      noise = noise.view(*noise.shape[:-1], *input.event_shape)
  
      # Handle NaN values if enabled
      nan_policy = settings.observation_nan_policy.value()
      if nan_policy == "mask":
          observed = settings.observation_nan_policy._get_observed(
              target, input.event_shape
          )
          input = MultivariateNormal(
              mean=input.mean[..., observed],
              covariance_matrix=MaskedLinearOperator(
                  input.lazy_covariance_matrix,
                  observed.reshape(-1),
                  observed.reshape(-1),
              ),
          )
          noise = noise[..., observed]
          target = target[..., observed]
      elif nan_policy == "fill":
          missing = torch.isnan(target)
          target = settings.observation_nan_policy._fill_tensor(target)
  
      mean, variance = input.mean, input.variance
      res = (
          ((target - mean).square() + variance) / noise
          + noise.log()
          + math.log(2 * math.pi)
      )
      res = res.mul(-0.5)
  
      if nan_policy == "fill":
          res = res * ~missing
  
      # Do appropriate summation for multitask Gaussian likelihoods
      num_event_dim = len(input.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 3 for calling the _GaussianLikelihoodBase obj's underlying member method code with example usage: obj.expected_log_prob(target, input) and returns: res