class_docstr: Base class wrapper for a stochastic variational Gaussian Process (SVGP)
  model [hensman2013svgp]_.
  
  Uses by default pivoted Cholesky initialization for allocating inducing points,
  however, custom inducing point allocators can be provided.
docstr: Args:
      train_X: Training inputs (due to the ability of the SVGP to sub-sample
          this does not have to be all of the training inputs).
      train_Y: Not used.
      num_outputs: Number of output responses per input.
      covar_module: Kernel function. If omitted, uses a `MaternKernel`.
      mean_module: Mean of GP model. If omitted, uses a `ConstantMean`.
      variational_distribution: Type of variational distribution to use
          (default: CholeskyVariationalDistribution), the properties of the
          variational distribution will encourage scalability or ease of
          optimization.
      variational_strategy: Type of variational strategy to use (default:
          VariationalStrategy). The default setting uses "whitening" of the
          variational distribution to make training easier.
      inducing_points: The number or specific locations of the inducing points.
      inducing_point_allocator: The `InducingPointAllocator` used to
          initialize the inducing point locations. If omitted,
          uses `GreedyVarianceReduction`.
code: def __init__(
      self,
      train_X: Tensor,
      train_Y: Optional[Tensor] = None,
      num_outputs: int = 1,
      learn_inducing_points=True,
      covar_module: Optional[Kernel] = None,
      mean_module: Optional[Mean] = None,
      variational_distribution: Optional[
          _VariationalDistribution
      ] = None,
      variational_strategy: Type[
          _VariationalStrategy
      ] = VariationalStrategy,
      inducing_points: Optional[Union[Tensor, int]] = None,
      inducing_point_allocator: Optional[InducingPointAllocator] = None,
  ) -> None:
      r"""
      Args:
          train_X: Training inputs (due to the ability of the SVGP to sub-sample
              this does not have to be all of the training inputs).
          train_Y: Not used.
          num_outputs: Number of output responses per input.
          covar_module: Kernel function. If omitted, uses a `MaternKernel`.
          mean_module: Mean of GP model. If omitted, uses a `ConstantMean`.
          variational_distribution: Type of variational distribution to use
              (default: CholeskyVariationalDistribution), the properties of the
              variational distribution will encourage scalability or ease of
              optimization.
          variational_strategy: Type of variational strategy to use (default:
              VariationalStrategy). The default setting uses "whitening" of the
              variational distribution to make training easier.
          inducing_points: The number or specific locations of the inducing points.
          inducing_point_allocator: The `InducingPointAllocator` used to
              initialize the inducing point locations. If omitted,
              uses `GreedyVarianceReduction`.
      """
      # We use the model subclass wrapper to deal with input / outcome transforms.
      # The number of outputs will be correct here due to the check in
      # SingleTaskVariationalGP.
      input_batch_shape = train_X.shape[:-2]
      aug_batch_shape = copy.deepcopy(input_batch_shape)
      if num_outputs > 1:
          aug_batch_shape += torch.Size((num_outputs,))
      self._aug_batch_shape = aug_batch_shape
  
      if covar_module is None:
          covar_module = get_matern_kernel_with_gamma_prior(
              ard_num_dims=train_X.shape[-1],
              batch_shape=self._aug_batch_shape,
          ).to(train_X)
          self._subset_batch_dict = {
              "mean_module.constant": -2,
              "covar_module.raw_outputscale": -1,
              "covar_module.base_kernel.raw_lengthscale": -3,
          }
  
      if inducing_point_allocator is None:
          inducing_point_allocator = GreedyVarianceReduction()
  
      # initialize inducing points if they are not given
      if not isinstance(inducing_points, Tensor):
          if inducing_points is None:
              # number of inducing points is 25% the number of data points
              # as a heuristic
              inducing_points = int(0.25 * train_X.shape[-2])
  
          inducing_points = (
              inducing_point_allocator.allocate_inducing_points(
                  inputs=train_X,
                  covar_module=covar_module,
                  num_inducing=inducing_points,
                  input_batch_shape=input_batch_shape,
              )
          )
  
      if variational_distribution is None:
          variational_distribution = CholeskyVariationalDistribution(
              num_inducing_points=inducing_points.shape[-2],
              batch_shape=self._aug_batch_shape,
          )
  
      variational_strategy_instance = variational_strategy(
          self,
          inducing_points=inducing_points,
          variational_distribution=variational_distribution,
          learn_inducing_locations=learn_inducing_points,
      )
  
      # wrap variational models in independent multi-task variational strategy
      if num_outputs > 1:
          variational_strategy_instance = IndependentMultitaskVariationalStrategy(
              base_variational_strategy=variational_strategy_instance,
              num_tasks=num_outputs,
              task_dim=-1,
          )
      super().__init__(
          variational_strategy=variational_strategy_instance
      )
  
      self.mean_module = (
          ConstantMean(batch_shape=self._aug_batch_shape).to(train_X)
          if mean_module is None
          else mean_module
      )
  
      self.covar_module = covar_module
  
imports: from __future__ import annotations
  import copy
  import warnings
  from typing import Optional, Type, TypeVar, Union
  import torch
  from botorch.models.gpytorch import GPyTorchModel
  from botorch.models.transforms.input import InputTransform
  from botorch.models.transforms.outcome import OutcomeTransform
  from botorch.models.utils import validate_input_scaling
  from botorch.models.utils.gpytorch_modules import get_gaussian_likelihood_with_gamma_prior, get_matern_kernel_with_gamma_prior
  from botorch.models.utils.inducing_point_allocators import GreedyVarianceReduction, InducingPointAllocator
  from botorch.posteriors.gpytorch import GPyTorchPosterior
  from gpytorch.distributions import MultivariateNormal
  from gpytorch.kernels import Kernel
  from gpytorch.likelihoods import GaussianLikelihood, Likelihood, MultitaskGaussianLikelihood
  from gpytorch.means import ConstantMean, Mean
  from gpytorch.models import ApproximateGP
  from gpytorch.utils.memoize import clear_cache_hook
  from gpytorch.variational import _VariationalDistribution, _VariationalStrategy, CholeskyVariationalDistribution, IndependentMultitaskVariationalStrategy, VariationalStrategy
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 1 to create a new _SingleTaskVariationalGP object from inherited base classes: ApproximateGP with example: obj = _SingleTaskVariationalGP(train_X, train_Y, num_outputs, learn_inducing_points, covar_module, mean_module, variational_distribution, variational_strategy, inducing_points, inducing_point_allocator)