class_docstr: Marginal distribution of a Gaussian process at finitely many points.
  
  A Gaussian process (GP) is an indexed collection of random variables, any
  finite collection of which are jointly Gaussian. While this definition applies
  to finite index sets, it is typically implicit that the index set is infinite;
  in applications, it is often some finite dimensional real or complex vector
  space. In such cases, the GP may be thought of as a distribution over
  (real- or complex-valued) functions defined over the index set.
  
  Just as Gaussian distributions are fully specified by their first and second
  moments, a Gaussian process can be completely specified by a mean and
  covariance function. Let `S` denote the index set and `K` the space in which
  each indexed random variable takes its values (again, often R or C). The mean
  function is then a map `m: S -> K`, and the covariance function, or kernel, is
  a positive-definite function `k: (S x S) -> K`. The properties of functions
  drawn from a GP are entirely dictated (up to translation) by the form of the
  kernel function.
  
  This `Distribution` represents the marginal joint distribution over function
  values at a given finite collection of points `[x[1], ..., x[N]]` from the
  index set `S`. By definition, this marginal distribution is just a
  multivariate normal distribution, whose mean is given by the vector
  `[ m(x[1]), ..., m(x[N]) ]` and whose covariance matrix is constructed from
  pairwise applications of the kernel function to the given inputs:
  
  ```none
      | k(x[1], x[1])    k(x[1], x[2])  ...  k(x[1], x[N]) |
      | k(x[2], x[1])    k(x[2], x[2])  ...  k(x[2], x[N]) |
      |      ...              ...                 ...      |
      | k(x[N], x[1])    k(x[N], x[2])  ...  k(x[N], x[N]) |
  ```
  
  For this to be a valid covariance matrix, it must be symmetric and positive
  definite; hence the requirement that `k` be a positive definite function
  (which, by definition, says that the above procedure will yield PD matrices).
  
  We also support the inclusion of zero-mean Gaussian noise in the model, via
  the `observation_noise_variance` parameter. This augments the generative model
  to
  
  ```none
  f ~ GP(m, k)
  (y[i] | f, x[i]) ~ Normal(f(x[i]), s)
  ```
  
  where
  
    * `m` is the mean function
    * `k` is the covariance kernel function
    * `f` is the function drawn from the GP
    * `x[i]` are the index points at which the function is observed
    * `y[i]` are the observed values at the index points
    * `s` is the scale of the observation noise.
  
  Note that this class represents an *unconditional* Gaussian process; it does
  not implement posterior inference conditional on observed function
  evaluations. This class is useful, for example, if one wishes to combine a GP
  prior with a non-conjugate likelihood using MCMC to sample from the posterior.
  
  #### Mathematical Details
  
  The probability density function (pdf) is a multivariate normal whose
  parameters are derived from the GP's properties:
  
  ```none
  pdf(x; index_points, mean_fn, kernel) = exp(-0.5 * y) / Z
  K = (kernel.matrix(index_points, index_points) +
       observation_noise_variance * eye(N))
  y = (x - mean_fn(index_points))^T @ K @ (x - mean_fn(index_points))
  Z = (2 * pi)**(.5 * N) |det(K)|**(.5)
  ```
  
  where:
  
  * `index_points` are points in the index set over which the GP is defined,
  * `mean_fn` is a callable mapping the index set to the GP's mean values,
  * `kernel` is `PositiveSemidefiniteKernel`-like and represents the covariance
    function of the GP,
  * `observation_noise_variance` represents (optional) observation noise.
  * `eye(N)` is an N-by-N identity matrix.
  
  #### Examples
  
  ##### Draw joint samples from a GP prior
  
  ```python
  import numpy as np
  import tensorflow.compat.v2 as tf
  import tensorflow_probability as tfp
  
  tfd = tfp.distributions
  psd_kernels = tfp.math.psd_kernels
  
  num_points = 100
  # Index points should be a collection (100, here) of feature vectors. In this
  # example, we're using 1-d vectors, so we just need to reshape the output from
  # np.linspace, to give a shape of (100, 1).
  index_points = np.expand_dims(np.linspace(-1., 1., num_points), -1)
  
  # Define a kernel with default parameters.
  kernel = psd_kernels.ExponentiatedQuadratic()
  
  gp = tfd.GaussianProcess(kernel, index_points)
  
  samples = gp.sample(10)
  # ==> 10 independently drawn, joint samples at `index_points`
  
  noisy_gp = tfd.GaussianProcess(
      kernel=kernel,
      index_points=index_points,
      observation_noise_variance=.05)
  noisy_samples = noisy_gp.sample(10)
  # ==> 10 independently drawn, noisy joint samples at `index_points`
  ```
  
  ##### Optimize kernel parameters via maximum marginal likelihood.
  
  ```python
  # Suppose we have some data from a known function. Note the index points in
  # general have shape `[b1, ..., bB, f1, ..., fF]` (here we assume `F == 1`),
  # so we need to explicitly consume the feature dimensions (just the last one
  # here).
  f = lambda x: np.sin(10*x[..., 0]) * np.exp(-x[..., 0]**2)
  observed_index_points = np.expand_dims(np.random.uniform(-1., 1., 50), -1)
  # Squeeze to take the shape from [50, 1] to [50].
  observed_values = f(observed_index_points)
  
  # Define a kernel with trainable parameters.
  kernel = psd_kernels.ExponentiatedQuadratic(
      amplitude=tf.Variable(1., dtype=np.float64, name='amplitude'),
      length_scale=tf.Variable(1., dtype=np.float64, name='length_scale'))
  
  gp = tfd.GaussianProcess(kernel, observed_index_points)
  
  optimizer = tf_keras.optimizers.Adam()
  
  @tf.function
  def optimize():
    with tf.GradientTape() as tape:
      loss = -gp.log_prob(observed_values)
    grads = tape.gradient(loss, gp.trainable_variables)
    optimizer.apply_gradients(zip(grads, gp.trainable_variables))
    return loss
  
  for i in range(1000):
    neg_log_likelihood = optimize()
    if i % 100 == 0:
      print("Step {}: NLL = {}".format(i, neg_log_likelihood))
  print("Final NLL = {}".format(neg_log_likelihood))
  ```
class_docstr_tok: ["Marginal","distribution","of","a","Gaussian","process","at","finitely","many","points",".","A","Gaussian","process","(","GP",")","is","an","indexed","collection","of","random","variables",",","any","finite","collection","of","which","are","jointly","Gaussian",".","While","this","definition","applies","to","finite","index","sets",",","it","is","typically","implicit","that","the","index","set","is","infinite",";","in","applications",",","it","is","often","some","finite","dimensional","real","or","complex","vector","space",".","In","such","cases",",","the","GP","may","be","thought","of","as","a","distribution","over","(","real-","or","complex-valued",")","functions","defined","over","the","index","set",".","Just","as","Gaussian","distributions","are","fully","specified","by","their","first","and","second","moments",",","a","Gaussian","process","can","be","completely","specified","by","a","mean","and","covariance","function",".","Let","`","S","`","denote","the","index","set","and","`","K","`","the","space","in","which","each","indexed","random","variable","takes","its","values","(","again",",","often","R","or","C",")",".","The","mean","function","is","then","a","map","`","m",":","S","-",">","K","`",",","and","the","covariance","function",",","or","kernel",",","is","a","positive-definite","function","`","k",":","(","S","x","S",")","-",">","K","`",".","The","properties","of","functions","drawn","from","a","GP","are","entirely","dictated","(","up","to","translation",")","by","the","form","of","the","kernel","function",".","This","`","Distribution","`","represents","the","marginal","joint","distribution","over","function","values","at","a","given","finite","collection","of","points","`","[","x","[","1","]",",","...",",","x","[","N","]","]","`","from","the","index","set","`","S","`",".","By","definition",",","this","marginal","distribution","is","just","a","multivariate","normal","distribution",",","whose","mean","is","given","by","the","vector","`","[","m","(","x","[","1","]",")",",","...",",","m","(","x","[","N","]",")","]","`","and","whose","covariance","matrix","is","constructed","from","pairwise","applications","of","the","kernel","function","to","the","given","inputs",":","``","`","none","|","k","(","x","[","1","]",",","x","[","1","]",")","k","(","x","[","1","]",",","x","[","2","]",")","...","k","(","x","[","1","]",",","x","[","N","]",")","|","|","k","(","x","[","2","]",",","x","[","1","]",")","k","(","x","[","2","]",",","x","[","2","]",")","...","k","(","x","[","2","]",",","x","[","N","]",")","|","|","...","...","...","|","|","k","(","x","[","N","]",",","x","[","1","]",")","k","(","x","[","N","]",",","x","[","2","]",")","...","k","(","x","[","N","]",",","x","[","N","]",")","|","``","`","For","this","to","be","a","valid","covariance","matrix",",","it","must","be","symmetric","and","positive","definite",";","hence","the","requirement","that","`","k","`","be","a","positive","definite","function","(","which",",","by","definition",",","says","that","the","above","procedure","will","yield","PD","matrices",")",".","We","also","support","the","inclusion","of","zero-mean","Gaussian","noise","in","the","model",",","via","the","`","observation_noise_variance","`","parameter",".","This","augments","the","generative","model","to","``","`","none","f","~","GP","(","m",",","k",")","(","y","[","i","]","|","f",",","x","[","i","]",")","~","Normal","(","f","(","x","[","i","]",")",",","s",")","``","`","where","*","`","m","`","is","the","mean","function","*","`","k","`","is","the","covariance","kernel","function","*","`","f","`","is","the","function","drawn","from","the","GP","*","`","x","[","i","]","`","are","the","index","points","at","which","the","function","is","observed","*","`","y","[","i","]","`","are","the","observed","values","at","the","index","points","*","`","s","`","is","the","scale","of","the","observation","noise",".","Note","that","this","class","represents","an","*","unconditional","*","Gaussian","process",";","it","does","not","implement","posterior","inference","conditional","on","observed","function","evaluations",".","This","class","is","useful",",","for","example",",","if","one","wishes","to","combine","a","GP","prior","with","a","non-conjugate","likelihood","using","MCMC","to","sample","from","the","posterior",".","#","#","#","#","Mathematical","Details","The","probability","density","function","(","pdf",")","is","a","multivariate","normal","whose","parameters","are","derived","from","the","GP","'s","properties",":","``","`","none","pdf","(","x",";","index_points",",","mean_fn",",","kernel",")","=","exp","(","-0.5","*","y",")","\/","Z","K","=","(","kernel.matrix","(","index_points",",","index_points",")","+","observation_noise_variance","*","eye","(","N",")",")","y","=","(","x","-","mean_fn","(","index_points",")",")","^T","@","K","@","(","x","-","mean_fn","(","index_points",")",")","Z","=","(","2","*","pi",")","*","*","(",".5","*","N",")","|det","(","K",")","|","*","*","(",".5",")","``","`","where",":","*","`","index_points","`","are","points","in","the","index","set","over","which","the","GP","is","defined",",","*","`","mean_fn","`","is","a","callable","mapping","the","index","set","to","the","GP","'s","mean","values",",","*","`","kernel","`","is","`","PositiveSemidefiniteKernel","`","-like","and","represents","the","covariance","function","of","the","GP",",","*","`","observation_noise_variance","`","represents","(","optional",")","observation","noise",".","*","`","eye","(","N",")","`","is","an","N-by-N","identity","matrix",".","#","#","#","#","Examples","#","#","#","#","#","Draw","joint","samples","from","a","GP","prior","``","`","python","import","numpy","as","np","import","tensorflow.compat.v2","as","tf","import","tensorflow_probability","as","tfp","tfd","=","tfp.distributions","psd_kernels","=","tfp.math.psd_kernels","num_points","=","100","#","Index","points","should","be","a","collection","(","100",",","here",")","of","feature","vectors",".","In","this","#","example",",","we","'re","using","1-d","vectors",",","so","we","just","need","to","reshape","the","output","from","#","np.linspace",",","to","give","a","shape","of","(","100",",","1",")",".","index_points","=","np.expand_dims","(","np.linspace","(","-1.",",","1.",",","num_points",")",",","-1",")","#","Define","a","kernel","with","default","parameters",".","kernel","=","psd_kernels.ExponentiatedQuadratic","(",")","gp","=","tfd.GaussianProcess","(","kernel",",","index_points",")","samples","=","gp.sample","(","10",")","#","==",">","10","independently","drawn",",","joint","samples","at","`","index_points","`","noisy_gp","=","tfd.GaussianProcess","(","kernel=kernel",",","index_points=index_points",",","observation_noise_variance=.05",")","noisy_samples","=","noisy_gp.sample","(","10",")","#","==",">","10","independently","drawn",",","noisy","joint","samples","at","`","index_points","`","``","`","#","#","#","#","#","Optimize","kernel","parameters","via","maximum","marginal","likelihood",".","``","`","python","#","Suppose","we","have","some","data","from","a","known","function",".","Note","the","index","points","in","#","general","have","shape","`","[","b1",",","...",",","bB",",","f1",",","...",",","fF","]","`","(","here","we","assume","`","F","==","1","`",")",",","#","so","we","need","to","explicitly","consume","the","feature","dimensions","(","just","the","last","one","#","here",")",".","f","=","lambda","x",":","np.sin","(","10","*","x","[","...",",","0","]",")","*","np.exp","(","-x","[","...",",","0","]","*","*","2",")","observed_index_points","=","np.expand_dims","(","np.random.uniform","(","-1.",",","1.",",","50",")",",","-1",")","#","Squeeze","to","take","the","shape","from","[","50",",","1","]","to","[","50","]",".","observed_values","=","f","(","observed_index_points",")","#","Define","a","kernel","with","trainable","parameters",".","kernel","=","psd_kernels.ExponentiatedQuadratic","(","amplitude=tf.Variable","(","1.",",","dtype=np.float64",",","name='amplitude","'",")",",","length_scale=tf.Variable","(","1.",",","dtype=np.float64",",","name='length_scale","'",")",")","gp","=","tfd.GaussianProcess","(","kernel",",","observed_index_points",")","optimizer","=","tf_keras.optimizers.Adam","(",")","@","tf.function","def","optimize","(",")",":","with","tf.GradientTape","(",")","as","tape",":","loss","=","-gp.log_prob","(","observed_values",")","grads","=","tape.gradient","(","loss",",","gp.trainable_variables",")","optimizer.apply_gradients","(","zip","(","grads",",","gp.trainable_variables",")",")","return","loss","for","i","in","range","(","1000",")",":","neg_log_likelihood","=","optimize","(",")","if","i","%","100","==","0",":","print","(","``","Step","{","}",":","NLL","=","{","}","''",".format","(","i",",","neg_log_likelihood",")",")","print","(","``","Final","NLL","=","{","}","''",".format","(","neg_log_likelihood",")",")","``","`"]
docstr: Instantiate a GaussianProcess Distribution.
  
  Args:
    kernel: `PositiveSemidefiniteKernel`-like instance representing the
      GP's covariance function.
    index_points: (nested) `Tensor` representing finite (batch of) vector(s)
      of points in the index set over which the GP is defined. Shape (or
      shape of each nested component) has the form `[b1, ..., bB, e, f1,
      ..., fF]` where `F` is the number of feature dimensions and must
      equal `kernel.feature_ndims` (or its corresponding nested component)
      and `e` is the number (size) of index points in each batch.
      Ultimately this distribution corresponds to a `e`-dimensional
      multivariate normal. The batch shape must be broadcastable with
      `kernel.batch_shape` and any batch dims yielded by `mean_fn`.
    mean_fn: Python `callable` that acts on `index_points` to produce a (batch
      of) vector(s) of mean values at `index_points`. Takes a (nested)
      `Tensor` of shape `[b1, ..., bB, e, f1, ..., fF]` and returns a `Tensor`
      whose shape is broadcastable with `[b1, ..., bB, e]`.
      Default value: `None` implies constant zero function.
    observation_noise_variance: `float` `Tensor` representing (batch of)
      scalar variance(s) of the noise in the Normal likelihood
      distribution of the model. If batched, the batch shape must be
      broadcastable with the shapes of all other batched parameters
      (`kernel.batch_shape`, `index_points`, etc.).
      Default value: `0.`
    marginal_fn: A Python callable that takes a location, covariance matrix,
      optional `validate_args`, `allow_nan_stats` and `name` arguments, and
      returns a multivariate normal subclass of `tfd.Distribution`.
      At most one of `cholesky_fn` and `marginal_fn` should be set.
      Default value: `None`, in which case a Cholesky-factorizing function
      is created using `make_cholesky_factored_marginal_fn` and the
      `cholesky_fn` argument.
    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. At most one of `cholesky_fn` and `marginal_fn` should be set.
    jitter: `float` scalar `Tensor` added to the diagonal of the covariance
      matrix to ensure positive definiteness of the covariance matrix, when
      `marginal_fn` and `cholesky_fn` is None.
      This argument is ignored if `cholesky_fn` is set.
      Default value: `1e-6`.
    validate_args: Python `bool`, default `False`. When `True` distribution
      parameters are checked for validity despite possibly degrading runtime
      performance. When `False` invalid inputs may silently render incorrect
      outputs.
      Default value: `False`.
    allow_nan_stats: Python `bool`, default `True`. When `True`,
      statistics (e.g., mean, mode, variance) use the value "`NaN`" to
      indicate the result is undefined. When `False`, an exception is raised
      if one or more of the statistic's batch members are undefined.
      Default value: `False`.
    parameters: For subclasses, a dict of constructor arguments.
    name: Python `str` name prefixed to Ops created by this class.
      Default value: "GaussianProcess".
    _check_marginal_cholesky_fn: Internal parameter -- do not use.
  
  Raises:
    ValueError: if `mean_fn` is not `None` and is not callable.
docstr_tok: ["Instantiate","a","GaussianProcess","Distribution",".","Args",":","kernel",":","`","PositiveSemidefiniteKernel","`","-like","instance","representing","the","GP","'s","covariance","function",".","index_points",":","(","nested",")","`","Tensor","`","representing","finite","(","batch","of",")","vector","(","s",")","of","points","in","the","index","set","over","which","the","GP","is","defined",".","Shape","(","or","shape","of","each","nested","component",")","has","the","form","`","[","b1",",","...",",","bB",",","e",",","f1",",","...",",","fF","]","`","where","`","F","`","is","the","number","of","feature","dimensions","and","must","equal","`","kernel.feature_ndims","`","(","or","its","corresponding","nested","component",")","and","`","e","`","is","the","number","(","size",")","of","index","points","in","each","batch",".","Ultimately","this","distribution","corresponds","to","a","`","e","`","-dimensional","multivariate","normal",".","The","batch","shape","must","be","broadcastable","with","`","kernel.batch_shape","`","and","any","batch","dims","yielded","by","`","mean_fn","`",".","mean_fn",":","Python","`","callable","`","that","acts","on","`","index_points","`","to","produce","a","(","batch","of",")","vector","(","s",")","of","mean","values","at","`","index_points","`",".","Takes","a","(","nested",")","`","Tensor","`","of","shape","`","[","b1",",","...",",","bB",",","e",",","f1",",","...",",","fF","]","`","and","returns","a","`","Tensor","`","whose","shape","is","broadcastable","with","`","[","b1",",","...",",","bB",",","e","]","`",".","Default","value",":","`","None","`","implies","constant","zero","function",".","observation_noise_variance",":","`","float","`","`","Tensor","`","representing","(","batch","of",")","scalar","variance","(","s",")","of","the","noise","in","the","Normal","likelihood","distribution","of","the","model",".","If","batched",",","the","batch","shape","must","be","broadcastable","with","the","shapes","of","all","other","batched","parameters","(","`","kernel.batch_shape","`",",","`","index_points","`",",","etc.",")",".","Default","value",":","`","0.","`","marginal_fn",":","A","Python","callable","that","takes","a","location",",","covariance","matrix",",","optional","`","validate_args","`",",","`","allow_nan_stats","`","and","`","name","`","arguments",",","and","returns","a","multivariate","normal","subclass","of","`","tfd.Distribution","`",".","At","most","one","of","`","cholesky_fn","`","and","`","marginal_fn","`","should","be","set",".","Default","value",":","`","None","`",",","in","which","case","a","Cholesky-factorizing","function","is","created","using","`","make_cholesky_factored_marginal_fn","`","and","the","`","cholesky_fn","`","argument",".","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",".","At","most","one","of","`","cholesky_fn","`","and","`","marginal_fn","`","should","be","set",".","jitter",":","`","float","`","scalar","`","Tensor","`","added","to","the","diagonal","of","the","covariance","matrix","to","ensure","positive","definiteness","of","the","covariance","matrix",",","when","`","marginal_fn","`","and","`","cholesky_fn","`","is","None",".","This","argument","is","ignored","if","`","cholesky_fn","`","is","set",".","Default","value",":","`","1e-6","`",".","validate_args",":","Python","`","bool","`",",","default","`","False","`",".","When","`","True","`","distribution","parameters","are","checked","for","validity","despite","possibly","degrading","runtime","performance",".","When","`","False","`","invalid","inputs","may","silently","render","incorrect","outputs",".","Default","value",":","`","False","`",".","allow_nan_stats",":","Python","`","bool","`",",","default","`","True","`",".","When","`","True","`",",","statistics","(","e.g.",",","mean",",","mode",",","variance",")","use","the","value","``","`","NaN","`","``","to","indicate","the","result","is","undefined",".","When","`","False","`",",","an","exception","is","raised","if","one","or","more","of","the","statistic","'s","batch","members","are","undefined",".","Default","value",":","`","False","`",".","parameters",":","For","subclasses",",","a","dict","of","constructor","arguments",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","class",".","Default","value",":","``","GaussianProcess","''",".","_check_marginal_cholesky_fn",":","Internal","parameter","--","do","not","use",".","Raises",":","ValueError",":","if","`","mean_fn","`","is","not","`","None","`","and","is","not","callable","."]
code: def __init__(
      self,
      kernel,
      index_points=None,
      mean_fn=None,
      observation_noise_variance=0.0,
      marginal_fn=None,
      cholesky_fn=None,
      jitter=1e-6,
      validate_args=False,
      allow_nan_stats=False,
      parameters=None,
      name="GaussianProcess",
      _check_marginal_cholesky_fn=True,
  ):
      """Instantiate a GaussianProcess Distribution.
  
      Args:
        kernel: `PositiveSemidefiniteKernel`-like instance representing the
          GP's covariance function.
        index_points: (nested) `Tensor` representing finite (batch of) vector(s)
          of points in the index set over which the GP is defined. Shape (or
          shape of each nested component) has the form `[b1, ..., bB, e, f1,
          ..., fF]` where `F` is the number of feature dimensions and must
          equal `kernel.feature_ndims` (or its corresponding nested component)
          and `e` is the number (size) of index points in each batch.
          Ultimately this distribution corresponds to a `e`-dimensional
          multivariate normal. The batch shape must be broadcastable with
          `kernel.batch_shape` and any batch dims yielded by `mean_fn`.
        mean_fn: Python `callable` that acts on `index_points` to produce a (batch
          of) vector(s) of mean values at `index_points`. Takes a (nested)
          `Tensor` of shape `[b1, ..., bB, e, f1, ..., fF]` and returns a `Tensor`
          whose shape is broadcastable with `[b1, ..., bB, e]`.
          Default value: `None` implies constant zero function.
        observation_noise_variance: `float` `Tensor` representing (batch of)
          scalar variance(s) of the noise in the Normal likelihood
          distribution of the model. If batched, the batch shape must be
          broadcastable with the shapes of all other batched parameters
          (`kernel.batch_shape`, `index_points`, etc.).
          Default value: `0.`
        marginal_fn: A Python callable that takes a location, covariance matrix,
          optional `validate_args`, `allow_nan_stats` and `name` arguments, and
          returns a multivariate normal subclass of `tfd.Distribution`.
          At most one of `cholesky_fn` and `marginal_fn` should be set.
          Default value: `None`, in which case a Cholesky-factorizing function
          is created using `make_cholesky_factored_marginal_fn` and the
          `cholesky_fn` argument.
        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. At most one of `cholesky_fn` and `marginal_fn` should be set.
        jitter: `float` scalar `Tensor` added to the diagonal of the covariance
          matrix to ensure positive definiteness of the covariance matrix, when
          `marginal_fn` and `cholesky_fn` is None.
          This argument is ignored if `cholesky_fn` is set.
          Default value: `1e-6`.
        validate_args: Python `bool`, default `False`. When `True` distribution
          parameters are checked for validity despite possibly degrading runtime
          performance. When `False` invalid inputs may silently render incorrect
          outputs.
          Default value: `False`.
        allow_nan_stats: Python `bool`, default `True`. When `True`,
          statistics (e.g., mean, mode, variance) use the value "`NaN`" to
          indicate the result is undefined. When `False`, an exception is raised
          if one or more of the statistic's batch members are undefined.
          Default value: `False`.
        parameters: For subclasses, a dict of constructor arguments.
        name: Python `str` name prefixed to Ops created by this class.
          Default value: "GaussianProcess".
        _check_marginal_cholesky_fn: Internal parameter -- do not use.
  
      Raises:
        ValueError: if `mean_fn` is not `None` and is not callable.
      """
      parameters = dict(locals()) if parameters is None else parameters
      with tf.name_scope(name) as name:
          input_dtype = dtype_util.common_dtype(
              dict(
                  kernel=kernel,
                  index_points=index_points,
              ),
              dtype_hint=nest_util.broadcast_structure(
                  kernel.feature_ndims, tf.float32
              ),
          )
  
          # If the input dtype is non-nested float, we infer a single dtype for the
          # input and the float parameters, which is also the dtype of the GP's
          # samples, log_prob, etc. If the input dtype is nested (or not float), we
          # do not use it to infer the GP's float dtype.
          if not tf.nest.is_nested(
              input_dtype
          ) and dtype_util.is_floating(input_dtype):
              dtype = dtype_util.common_dtype(
                  dict(
                      kernel=kernel,
                      index_points=index_points,
                      observation_noise_variance=observation_noise_variance,
                      jitter=jitter,
                  ),
                  dtype_hint=tf.float32,
              )
              input_dtype = dtype
          else:
              dtype = dtype_util.common_dtype(
                  dict(
                      observation_noise_variance=observation_noise_variance,
                      jitter=jitter,
                  ),
                  dtype_hint=tf.float32,
              )
  
          if index_points is not None:
              index_points = nest_util.convert_to_nested_tensor(
                  index_points,
                  dtype=input_dtype,
                  name="index_points",
                  convert_ref=False,
                  allow_packing=True,
              )
          jitter = tensor_util.convert_nonref_to_tensor(
              jitter, dtype=dtype, name="jitter"
          )
          observation_noise_variance = (
              tensor_util.convert_nonref_to_tensor(
                  observation_noise_variance,
                  dtype=dtype,
                  name="observation_noise_variance",
              )
          )
  
          self._kernel = kernel
          self._index_points = index_points
          # Default to a constant zero function, borrowing the dtype from
          # index_points to ensure consistency.
  
          self._mean_fn = stochastic_process_util.maybe_create_mean_fn(
              mean_fn, dtype
          )
          self._observation_noise_variance = observation_noise_variance
          self._jitter = jitter
          self._cholesky_fn = cholesky_fn
  
          if (
              _check_marginal_cholesky_fn
              and marginal_fn is not None
              and cholesky_fn is not None
          ):
              raise ValueError(
                  "At most one of `marginal_fn` and `cholesky_fn` should be set."
              )
          if marginal_fn is None:
              if cholesky_fn is None:
                  self._cholesky_fn = (
                      cholesky_util.make_cholesky_with_jitter_fn(jitter)
                  )
              self._marginal_fn = make_cholesky_factored_marginal_fn(
                  self._cholesky_fn
              )
          else:
              self._marginal_fn = marginal_fn
  
          with tf.name_scope("init"):
              super(GaussianProcess, self).__init__(
                  dtype=dtype,
                  reparameterization_type=reparameterization.FULLY_REPARAMETERIZED,
                  validate_args=validate_args,
                  allow_nan_stats=allow_nan_stats,
                  parameters=parameters,
                  name=name,
              )
  
imports: import functools
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  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 kullback_leibler
  from tensorflow_probability.python.distributions import mvn_linear_operator
  from tensorflow_probability.python.distributions.internal import stochastic_process_util
  from tensorflow_probability.python.internal import auto_composite_tensor
  from tensorflow_probability.python.internal import batch_shape_lib
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math import linalg
  from tensorflow.python.util import deprecation
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 to create a new GaussianProcess object from inherited base classes: distribution, tf.__internal__ with example: obj = GaussianProcess(kernel, index_points, mean_fn, observation_noise_variance, marginal_fn, cholesky_fn, jitter, validate_args, allow_nan_stats, parameters, name, _check_marginal_cholesky_fn)