docstr: Implements the fantasy strategy described in https://arxiv.org/abs/2103.01454.
docstr_tok: ["Implements","the","fantasy","strategy","described","in","https",":","\/\/arxiv.org\/abs\/2103.01454","."]
code: def get_fantasy_strategy(
      self,
      inputs,
      targets,
      full_inputs,
      full_targets,
      full_output,
      **kwargs,
  ):
      r"""
      Implements the fantasy strategy described in https://arxiv.org/abs/2103.01454.
      """
      full_mean, full_covar = (
          full_output.mean,
          full_output.lazy_covariance_matrix,
      )
  
      batch_shape = full_inputs[0].shape[:-2]
  
      full_mean = full_mean.view(*batch_shape, -1)
      num_train = self.num_train
  
      # Evaluate fant x train and fant x fant covariance matrices, leave train x train unevaluated.
      fant_fant_covar = full_covar[
          ..., num_train:, num_train:
      ].evaluate_kernel()
      fant_mean = full_mean[..., num_train:]
  
      fant_wmat = self.prepare_dense_wmat(fant_fant_covar)
  
      fant_likelihood = self.likelihood.get_fantasy_likelihood(**kwargs)
      fant_noise = fant_likelihood.noise_covar(
          fant_wmat.transpose(-1, -2)
          if len(fant_wmat.shape) > 2
          else fant_wmat
      )
      fant_root_vector = fant_noise.sqrt_inv_matmul(
          fant_wmat.transpose(-1, -2)
      ).transpose(-1, -2)
  
      new_wmat = self.interp_inner_prod.add_low_rank(
          fant_root_vector.to_dense()
      )
      mean_diff = (targets - fant_mean).unsqueeze(-1)
      new_interp_response_cache = (
          self.interp_response_cache
          + fant_wmat.matmul(fant_noise.solve(mean_diff))
      )
  
      # Create new DefaultPredictionStrategy object
      fant_strat = self.__class__(
          train_inputs=full_inputs,
          train_prior_dist=self.train_prior_dist.__class__(
              full_mean, full_covar
          ),
          train_labels=full_targets,
          likelihood=fant_likelihood,
          uses_wiski=True,
      )
      add_to_cache(fant_strat, "interp_inner_prod", new_wmat)
      add_to_cache(
          fant_strat, "interp_response_cache", new_interp_response_cache
      )
      return fant_strat
  
imports: import functools
  import string
  import warnings
  import torch
  from linear_operator import to_dense, to_linear_operator
  from linear_operator.operators import AddedDiagLinearOperator, BatchRepeatLinearOperator, ConstantMulLinearOperator, DenseLinearOperator, InterpolatedLinearOperator, LinearOperator, LowRankRootAddedDiagLinearOperator, MaskedLinearOperator, MatmulLinearOperator, RootLinearOperator, ZeroLinearOperator
  from linear_operator.utils.cholesky import psd_safe_cholesky
  from linear_operator.utils.interpolation import left_interp, left_t_interp
  from torch import Tensor
  from ..None import settings
  from ..distributions import MultitaskMultivariateNormal
  from ..lazy import LazyEvaluatedKernelTensor
  from ..utils.memoize import add_to_cache, cached, clear_cache_hook, pop_from_cache
label_desc: Use image node_id 4 for calling the InterpolatedPredictionStrategy obj's underlying member method code with example usage: obj.get_fantasy_strategy(inputs, targets, full_inputs, full_targets, full_output) and returns: fant_strat