code: def mean_standardized_log_loss(
      pred_dist: MultivariateNormal,
      test_y: torch.Tensor,
      train_y: Optional[torch.Tensor] = None,
  ):
      """
      Mean standardized log loss.
  
      Computes the average *standardized* log loss, which subtracts the loss obtained
      under the trivial model which predicts with the mean and variance of the training
      data from the mean log loss. See p.23 of Rasmussen and Williams (2006).
  
      If no training data is supplied, the mean log loss is computed.
      """
      combine_dim = (
          -2
          if isinstance(pred_dist, MultitaskMultivariateNormal)
          else -1
      )
  
      f_mean = pred_dist.mean
      f_var = pred_dist.variance
      loss_model = (
          0.5 * torch.log(2 * pi * f_var)
          + torch.square(test_y - f_mean) / (2 * f_var)
      ).mean(dim=combine_dim)
      res = loss_model
  
      if train_y is not None:
          data_mean = train_y.mean(dim=combine_dim)
          data_var = train_y.var()
          loss_trivial_model = (
              0.5 * torch.log(2 * pi * data_var)
              + torch.square(test_y - data_mean) / (2 * data_var)
          ).mean(dim=combine_dim)
          res = res - loss_trivial_model
  
      return res
  
file_path: gpytorch/gpytorch/metrics/metrics.py
imports: from math import pi
  from typing import Optional
  import torch
  from ..distributions import MultitaskMultivariateNormal, MultivariateNormal
label_desc: Use image node_id 5 for calling a global function with example usage: mean_standardized_log_loss(pred_dist, test_y, train_y) and returns: res