class_docstr: A PSDKernel which computes the variational kernel from [Titsias, 2009].
  
  The VariationalGaussianProcess can be cast as a special case of
  GaussianProcess with a particular class of kernel function. The idea is that
  instead of conditioning exactly on data, which would cost us time cubic in the
  number of data points, we learn a variational posterior over function values
  at a set of so-called "inducing points" and then make predictions by
  marginalizing over the variational posterior over the function values at the
  inducing point locations. This yields a new model, which is again just a GP
  but with a more complicated kernel function than we started with (similar to
  the way in which an exact GP posterior is just another GP with a more
  complicated kernel function).
  
  Having established that context, we can describe the `_VariationalKernel`. It
  is parameterized by
    - a `base_kernel` (another PSDKernel instance), the kernel we use to model
      the covariance structure of our true GP model,
    - `inducing_index_points`, the locations of the inducing points in the index
      set,
    - `variational_scale`, the scale matrix of the (multivariate Normal)
      variational posterior in the approximate model, that is, the scale matrix
      of the variational distribution `q(f(z)) ~= p(f(z) | f(z))`, where `z` are
      the inducing point locations, `x` the observation locations, and `f(.)`
      the function values at those locations.
  
  More precisely, it computes its value on inputs `x`, `y` as follows where, for
  brevity,
  
    - `z` are the aforementioned `inducing_index_points`
    - `var_scale` is the variational scale matrix
    - `k0` is the function represented by `base_kernel`
    - `k` is an the function represented by this class
  
  ```none
    kxy = k0(x, y)
    kxz = k0(x, z)
    kzy = k0(z, y)
    kzz = k0(z, z)
    k(x, y) = (kxy -
               kxz @ inv(kzz) @ kzy +
               kxz @ inv(kzz) @ var_scale @ var_scale^T @ inv(kzz) @ kzy)
  ```
class_docstr_tok: ["A","PSDKernel","which","computes","the","variational","kernel","from","[","Titsias",",","2009","]",".","The","VariationalGaussianProcess","can","be","cast","as","a","special","case","of","GaussianProcess","with","a","particular","class","of","kernel","function",".","The","idea","is","that","instead","of","conditioning","exactly","on","data",",","which","would","cost","us","time","cubic","in","the","number","of","data","points",",","we","learn","a","variational","posterior","over","function","values","at","a","set","of","so-called","``","inducing","points","''","and","then","make","predictions","by","marginalizing","over","the","variational","posterior","over","the","function","values","at","the","inducing","point","locations",".","This","yields","a","new","model",",","which","is","again","just","a","GP","but","with","a","more","complicated","kernel","function","than","we","started","with","(","similar","to","the","way","in","which","an","exact","GP","posterior","is","just","another","GP","with","a","more","complicated","kernel","function",")",".","Having","established","that","context",",","we","can","describe","the","`","_VariationalKernel","`",".","It","is","parameterized","by","-","a","`","base_kernel","`","(","another","PSDKernel","instance",")",",","the","kernel","we","use","to","model","the","covariance","structure","of","our","true","GP","model",",","-","`","inducing_index_points","`",",","the","locations","of","the","inducing","points","in","the","index","set",",","-","`","variational_scale","`",",","the","scale","matrix","of","the","(","multivariate","Normal",")","variational","posterior","in","the","approximate","model",",","that","is",",","the","scale","matrix","of","the","variational","distribution","`","q","(","f","(","z",")",")","~=","p","(","f","(","z",")","|","f","(","z",")",")","`",",","where","`","z","`","are","the","inducing","point","locations",",","`","x","`","the","observation","locations",",","and","`","f","(",".",")","`","the","function","values","at","those","locations",".","More","precisely",",","it","computes","its","value","on","inputs","`","x","`",",","`","y","`","as","follows","where",",","for","brevity",",","-","`","z","`","are","the","aforementioned","`","inducing_index_points","`","-","`","var_scale","`","is","the","variational","scale","matrix","-","`","k0","`","is","the","function","represented","by","`","base_kernel","`","-","`","k","`","is","an","the","function","represented","by","this","class","``","`","none","kxy","=","k0","(","x",",","y",")","kxz","=","k0","(","x",",","z",")","kzy","=","k0","(","z",",","y",")","kzz","=","k0","(","z",",","z",")","k","(","x",",","y",")","=","(","kxy","-","kxz","@","inv","(","kzz",")","@","kzy","+","kxz","@","inv","(","kzz",")","@","var_scale","@","var_scale^T","@","inv","(","kzz",")","@","kzy",")","``","`"]
docstr: Construct a _VariationalKernel instance.
  
  Args:
    base_kernel: a `PositiveSemidefiniteKernel` instance, the kernel used to
      build the constituent kernel matrices this kernel's computation is based
      around.
    inducing_index_points: a `Tensor` of shape `[..., N, F]`, where `N` is the
      number of such inputs ("examples" in the PSDKernels parlance) and `F`
      represents the feature shape of `base_kernel`. This set of index points,
      similar to the `inducing_index_points` argument to SchurComplement, will
      typically be the inducing points of the variational GP. Batch dimensions
      must be broadcast-compatible with the batch shape of `base_kernel` and
      `variational_scale`.
    variational_scale: a `Tensor` of shape `[..., N, N]` where `N` is the
      number of examples in `inducing_index_points`. Batch dimensions must be
      broadcast-compatible with the batch shape of `base_kernel` and
      `inducing_index_points`.
    cholesky_fn: Callable which takes a single (batch) matrix argument and
      returns a Cholesky-like lower triangular factor.  Default value: `None`,
      in which case `make_cholesky_with_jitter_fn` is used with the `jitter`
      parameter.
    use_whitening_transform: Python `bool`. Whether to reparameterize
      the variational scale as `m = chol(K_zz)m', s = chol(K_zz)s'`, where
      `chol(K_zz)` is the cholesky factor of the kernel at the
      `inducing_index_points`, `s` is the variational scale, and `s'` is the
      reparameterization when this parameter is True.
      When the number of inducing points is smaller than number of
      observations, this can accelerate training.
      Default value: `False`.
    jitter: `float` scalar `Tensor` added to the diagonal of the covariance
      matrix to ensure positive definiteness of the covariance matrix.
      This argument is ignored if `cholesky_fn` is set.
      Default value: `1e-6`.
    name: Python `str` name prefixed to `Op`A created by this class.
      Default value: `"VariationalKernel"`
docstr_tok: ["Construct","a","_VariationalKernel","instance",".","Args",":","base_kernel",":","a","`","PositiveSemidefiniteKernel","`","instance",",","the","kernel","used","to","build","the","constituent","kernel","matrices","this","kernel","'s","computation","is","based","around",".","inducing_index_points",":","a","`","Tensor","`","of","shape","`","[","...",",","N",",","F","]","`",",","where","`","N","`","is","the","number","of","such","inputs","(","``","examples","''","in","the","PSDKernels","parlance",")","and","`","F","`","represents","the","feature","shape","of","`","base_kernel","`",".","This","set","of","index","points",",","similar","to","the","`","inducing_index_points","`","argument","to","SchurComplement",",","will","typically","be","the","inducing","points","of","the","variational","GP",".","Batch","dimensions","must","be","broadcast-compatible","with","the","batch","shape","of","`","base_kernel","`","and","`","variational_scale","`",".","variational_scale",":","a","`","Tensor","`","of","shape","`","[","...",",","N",",","N","]","`","where","`","N","`","is","the","number","of","examples","in","`","inducing_index_points","`",".","Batch","dimensions","must","be","broadcast-compatible","with","the","batch","shape","of","`","base_kernel","`","and","`","inducing_index_points","`",".","cholesky_fn",":","Callable","which","takes","a","single","(","batch",")","matrix","argument","and","returns","a","Cholesky-like","lower","triangular","factor",".","Default","value",":","`","None","`",",","in","which","case","`","make_cholesky_with_jitter_fn","`","is","used","with","the","`","jitter","`","parameter",".","use_whitening_transform",":","Python","`","bool","`",".","Whether","to","reparameterize","the","variational","scale","as","`","m","=","chol","(","K_zz",")","m","'",",","s","=","chol","(","K_zz",")","s","'","`",",","where","`","chol","(","K_zz",")","`","is","the","cholesky","factor","of","the","kernel","at","the","`","inducing_index_points","`",",","`","s","`","is","the","variational","scale",",","and","`","s","'","`","is","the","reparameterization","when","this","parameter","is","True",".","When","the","number","of","inducing","points","is","smaller","than","number","of","observations",",","this","can","accelerate","training",".","Default","value",":","`","False","`",".","jitter",":","`","float","`","scalar","`","Tensor","`","added","to","the","diagonal","of","the","covariance","matrix","to","ensure","positive","definiteness","of","the","covariance","matrix",".","This","argument","is","ignored","if","`","cholesky_fn","`","is","set",".","Default","value",":","`","1e-6","`",".","name",":","Python","`","str","`","name","prefixed","to","`","Op","`","A","created","by","this","class",".","Default","value",":","`","``","VariationalKernel","''","`"]
code: def __init__(
      self,
      base_kernel,
      inducing_index_points,
      variational_scale,
      cholesky_fn=None,
      use_whitening_transform=False,
      jitter=1e-6,
      name="VariationalKernel",
  ):
      """Construct a _VariationalKernel instance.
  
      Args:
        base_kernel: a `PositiveSemidefiniteKernel` instance, the kernel used to
          build the constituent kernel matrices this kernel's computation is based
          around.
        inducing_index_points: a `Tensor` of shape `[..., N, F]`, where `N` is the
          number of such inputs ("examples" in the PSDKernels parlance) and `F`
          represents the feature shape of `base_kernel`. This set of index points,
          similar to the `inducing_index_points` argument to SchurComplement, will
          typically be the inducing points of the variational GP. Batch dimensions
          must be broadcast-compatible with the batch shape of `base_kernel` and
          `variational_scale`.
        variational_scale: a `Tensor` of shape `[..., N, N]` where `N` is the
          number of examples in `inducing_index_points`. Batch dimensions must be
          broadcast-compatible with the batch shape of `base_kernel` and
          `inducing_index_points`.
        cholesky_fn: Callable which takes a single (batch) matrix argument and
          returns a Cholesky-like lower triangular factor.  Default value: `None`,
          in which case `make_cholesky_with_jitter_fn` is used with the `jitter`
          parameter.
        use_whitening_transform: Python `bool`. Whether to reparameterize
          the variational scale as `m = chol(K_zz)m', s = chol(K_zz)s'`, where
          `chol(K_zz)` is the cholesky factor of the kernel at the
          `inducing_index_points`, `s` is the variational scale, and `s'` is the
          reparameterization when this parameter is True.
          When the number of inducing points is smaller than number of
          observations, this can accelerate training.
          Default value: `False`.
        jitter: `float` scalar `Tensor` added to the diagonal of the covariance
          matrix to ensure positive definiteness of the covariance matrix.
          This argument is ignored if `cholesky_fn` is set.
          Default value: `1e-6`.
        name: Python `str` name prefixed to `Op`A created by this class.
          Default value: `"VariationalKernel"`
      """
      parameters = dict(locals())
      with tf.name_scope(name):
          dtype = dtype_util.common_dtype(
              [inducing_index_points, variational_scale, jitter],
              dtype_hint=tf.float32,
          )
  
          self._use_whitening_transform = use_whitening_transform
          self._base_kernel = base_kernel
          self._inducing_index_points = (
              tensor_util.convert_nonref_to_tensor(
                  inducing_index_points,
                  dtype=dtype,
                  name="inducing_index_points",
              )
          )
          self._variational_scale = (
              tensor_util.convert_nonref_to_tensor(
                  variational_scale,
                  dtype=dtype,
                  name="variational_scale",
              )
          )
          self._cholesky_fn = cholesky_fn
  
          if cholesky_fn is None:
              self._cholesky_fn = (
                  cholesky_util.make_cholesky_with_jitter_fn(jitter)
              )
          self._jitter = tensor_util.convert_nonref_to_tensor(
              jitter, dtype=dtype, name="jitter"
          )
  
          def _compute_chol_kzz(z):
              kzz = base_kernel.matrix(z, z)
              result = self._cholesky_fn(kzz)
              return result
  
          self._chol_kzz = tfp_util.DeferredTensor(
              inducing_index_points,
              transform_fn=_compute_chol_kzz,
              shape=None,
              name="chol_kzz",
          )
  
          super(_VariationalKernel, self).__init__(
              feature_ndims=base_kernel.feature_ndims,
              dtype=dtype,
              name=name,
              parameters=parameters,
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python import util
  from tensorflow_probability.python.bijectors import fill_scale_tril
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import cholesky_util
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gaussian_process
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import mvn_linear_operator
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions.internal import stochastic_process_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math import linalg
  from tensorflow_probability.python.math.psd_kernels import positive_semidefinite_kernel
  from tensorflow_probability.python.math.psd_kernels.internal import util
label_desc: Use image node_id 1 to create a new _VariationalKernel object from inherited base classes: psd_kernel with example: obj = _VariationalKernel(base_kernel, inducing_index_points, variational_scale, cholesky_fn, use_whitening_transform, jitter, name)