class_docstr: This is the Sparse Variational GP (SVGP).
  
  The key reference is :cite:t:`hensman2014scalable`.
  
  For a use example see
  :doc:`../../../../notebooks/getting_started/classification_and_other_data_distributions`.
class_docstr_tok: ["This","is","the","Sparse","Variational","GP","(","SVGP",")",".","The","key","reference","is",":","cite",":","t",":","`","hensman2014scalable","`",".","For","a","use","example","see",":","doc",":","`","..","\/","..","\/","..","\/","..","\/notebooks\/getting_started\/classification_and_other_data_distributions","`","."]
docstr: Constructs the mean and cholesky of the covariance of the variational Gaussian posterior.
  If a user passes values for `q_mu` and `q_sqrt` the routine checks if they have consistent
  and correct shapes. If a user does not specify any values for `q_mu` and `q_sqrt`, the
  routine initializes them, their shape depends on `num_inducing` and `q_diag`.
  
  Note: most often the comments refer to the number of observations (=output dimensions) with
  P, number of latent GPs with L, and number of inducing points M. Typically P equals L,
  but when certain multioutput kernels are used, this can change.
  
  Parameters
  ----------
  :param num_inducing:
      Number of inducing variables, typically refered to as M.
  :param q_mu:
      Mean of the variational Gaussian posterior. If None the function will initialise
      the mean with zeros. If not None, the shape of `q_mu` is checked.
  :param q_sqrt:
      Cholesky of the covariance of the variational Gaussian posterior.
      If None the function will initialise `q_sqrt` with identity matrix.
      If not None, the shape of `q_sqrt` is checked, depending on `q_diag`.
  :param q_diag:
      Used to check if `q_mu` and `q_sqrt` have the correct shape or to
      construct them with the correct shape. If `q_diag` is true,
      `q_sqrt` is two dimensional and only holds the square root of the
      covariance diagonal elements. If False, `q_sqrt` is three dimensional.
docstr_tok: ["Constructs","the","mean","and","cholesky","of","the","covariance","of","the","variational","Gaussian","posterior",".","If","a","user","passes","values","for","`","q_mu","`","and","`","q_sqrt","`","the","routine","checks","if","they","have","consistent","and","correct","shapes",".","If","a","user","does","not","specify","any","values","for","`","q_mu","`","and","`","q_sqrt","`",",","the","routine","initializes","them",",","their","shape","depends","on","`","num_inducing","`","and","`","q_diag","`",".","Note",":","most","often","the","comments","refer","to","the","number","of","observations","(","=output","dimensions",")","with","P",",","number","of","latent","GPs","with","L",",","and","number","of","inducing","points","M.","Typically","P","equals","L",",","but","when","certain","multioutput","kernels","are","used",",","this","can","change",".","Parameters","--","--","--","--","--",":","param","num_inducing",":","Number","of","inducing","variables",",","typically","refered","to","as","M.",":","param","q_mu",":","Mean","of","the","variational","Gaussian","posterior",".","If","None","the","function","will","initialise","the","mean","with","zeros",".","If","not","None",",","the","shape","of","`","q_mu","`","is","checked",".",":","param","q_sqrt",":","Cholesky","of","the","covariance","of","the","variational","Gaussian","posterior",".","If","None","the","function","will","initialise","`","q_sqrt","`","with","identity","matrix",".","If","not","None",",","the","shape","of","`","q_sqrt","`","is","checked",",","depending","on","`","q_diag","`",".",":","param","q_diag",":","Used","to","check","if","`","q_mu","`","and","`","q_sqrt","`","have","the","correct","shape","or","to","construct","them","with","the","correct","shape",".","If","`","q_diag","`","is","true",",","`","q_sqrt","`","is","two","dimensional","and","only","holds","the","square","root","of","the","covariance","diagonal","elements",".","If","False",",","`","q_sqrt","`","is","three","dimensional","."]
code: def _init_variational_parameters(
      self,
      num_inducing: int,
      q_mu: Optional[AnyNDArray],
      q_sqrt: Optional[AnyNDArray],
      q_diag: bool,
  ) -> None:
      """
      Constructs the mean and cholesky of the covariance of the variational Gaussian posterior.
      If a user passes values for `q_mu` and `q_sqrt` the routine checks if they have consistent
      and correct shapes. If a user does not specify any values for `q_mu` and `q_sqrt`, the
      routine initializes them, their shape depends on `num_inducing` and `q_diag`.
  
      Note: most often the comments refer to the number of observations (=output dimensions) with
      P, number of latent GPs with L, and number of inducing points M. Typically P equals L,
      but when certain multioutput kernels are used, this can change.
  
      Parameters
      ----------
      :param num_inducing:
          Number of inducing variables, typically refered to as M.
      :param q_mu:
          Mean of the variational Gaussian posterior. If None the function will initialise
          the mean with zeros. If not None, the shape of `q_mu` is checked.
      :param q_sqrt:
          Cholesky of the covariance of the variational Gaussian posterior.
          If None the function will initialise `q_sqrt` with identity matrix.
          If not None, the shape of `q_sqrt` is checked, depending on `q_diag`.
      :param q_diag:
          Used to check if `q_mu` and `q_sqrt` have the correct shape or to
          construct them with the correct shape. If `q_diag` is true,
          `q_sqrt` is two dimensional and only holds the square root of the
          covariance diagonal elements. If False, `q_sqrt` is three dimensional.
      """
      q_mu = (
          np.zeros((num_inducing, self.num_latent_gps))
          if q_mu is None
          else q_mu
      )
      self.q_mu = Parameter(q_mu, dtype=default_float())  # [M, P]
  
      if q_sqrt is None:
          if q_diag:
              ones: AnyNDArray = np.ones(
                  (num_inducing, self.num_latent_gps),
                  dtype=default_float(),
              )
              self.q_sqrt = Parameter(
                  ones, transform=positive()
              )  # [M, P]
          else:
              np_q_sqrt: AnyNDArray = np.array(
                  [
                      np.eye(num_inducing, dtype=default_float())
                      for _ in range(self.num_latent_gps)
                  ]
              )
              self.q_sqrt = Parameter(
                  np_q_sqrt, transform=triangular()
              )  # [P, M, M]
      else:
          if q_diag:
              self.num_latent_gps = q_sqrt.shape[1]
              self.q_sqrt = Parameter(
                  q_sqrt, transform=positive()
              )  # [M, L|P]
          else:
              self.num_latent_gps = q_sqrt.shape[0]
              num_inducing = q_sqrt.shape[1]
              self.q_sqrt = Parameter(q_sqrt, transform=triangular())
  
imports: from typing import Optional
  import numpy
  import tensorflow
  from check_shapes import check_shapes, inherit_check_shapes
  from ..None import kullback_leiblers, posteriors
  from ..base import AnyNDArray, InputData, MeanAndVariance, Parameter, RegressionData
  from ..conditionals import conditional
  from ..config import default_float
  from ..inducing_variables import InducingVariables
  from ..kernels import Kernel
  from ..likelihoods import Likelihood
  from ..mean_functions import MeanFunction
  from ..utilities import positive, triangular
  from .model import GPModel
  from .training_mixins import ExternalDataTrainingLossMixin
  from .util import InducingVariablesLike, inducingpoint_wrapper
label_desc: Use image node_id 2 for calling the SVGP_deprecated obj's underlying member method code with example usage: obj._init_variational_parameters(num_inducing, q_mu, q_sqrt, q_diag) without return types