code: def _gaussian_update_exact(
      kernel: Kernel,
      points: Tensor,
      target_values: Tensor,
      sample_values: Tensor,
      noise_covariance: Optional[Union[Tensor, LinearOperator]] = None,
      scale_tril: Optional[Union[Tensor, LinearOperator]] = None,
      input_transform: Optional[TInputTransform] = None,
  ) -> GeneralizedLinearPath:
      # Prepare Cholesky factor of `Cov(y, y)` and noise sample values as needed
      if isinstance(noise_covariance, (NoneType, ZeroLinearOperator)):
          scale_tril = (
              kernel(points).cholesky()
              if scale_tril is None
              else scale_tril
          )
      else:
          noise_values = torch.randn_like(sample_values).unsqueeze(-1)
          noise_values = noise_covariance.cholesky() @ noise_values
          sample_values = sample_values + noise_values.squeeze(-1)
          scale_tril = (
              SumLinearOperator(
                  kernel(points), noise_covariance
              ).cholesky()
              if scale_tril is None
              else scale_tril
          )
  
      # Solve for `Cov(y, y)^{-1}(Y - f(X) - ε)`
      errors = target_values - sample_values
      weight = torch.cholesky_solve(
          errors.unsqueeze(-1), scale_tril.to_dense()
      )
  
      # Define update feature map and paths
      feature_map = KernelEvaluationMap(
          kernel=kernel,
          points=points,
          input_transform=input_transform,
      )
      return GeneralizedLinearPath(
          feature_map=feature_map, weight=weight.squeeze(-1)
      )
  
imports: from __future__ import annotations
  from typing import Any, Callable, Optional, Union
  import torch
  from botorch.models.approximate_gp import ApproximateGPyTorchModel
  from botorch.models.transforms.input import InputTransform
  from botorch.sampling.pathwise.features import KernelEvaluationMap
  from botorch.sampling.pathwise.paths import GeneralizedLinearPath, SamplePath
  from botorch.sampling.pathwise.utils import get_input_transform, get_train_inputs, get_train_targets, TInputTransform
  from botorch.utils.dispatcher import Dispatcher
  from botorch.utils.types import DEFAULT, NoneType
  from gpytorch.kernels.kernel import Kernel
  from gpytorch.likelihoods import _GaussianLikelihoodBase, Likelihood
  from gpytorch.models import ApproximateGP, ExactGP, GP
  from gpytorch.variational import VariationalStrategy
  from linear_operator.operators import LinearOperator, SumLinearOperator, ZeroLinearOperator
  from torch import Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: _gaussian_update_exact(kernel, points, target_values, sample_values, noise_covariance, scale_tril, input_transform) and returns: GeneralizedLinearPath