code: def _gen_gaussian_updating_example(x_dim, y_dim, seed):
      """An implementation of section 2.3.3 from [1].
  
      We initialize a joint distribution
  
      x ~ N(mu, Lambda^{-1})
      y ~ N(Ax, L^{-1})
  
      Then condition the model on an observation for y. We can test to confirm that
      Cov(p(x | y_obs)) is near to
  
      Sigma = (Lambda + A^T L A)^{-1}
  
      This test can actually check whether the posterior samples have the proper
      covariance, and whether the windowed tuning recovers 1 / diag(Sigma) as the
      diagonal scaling factor.
  
      References:
      [1] Bishop, Christopher M. Pattern Recognition and Machine Learning.
          Springer, 2006.
  
      Args:
        x_dim: int
        y_dim: int
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
      Returns:
        (tfd.JointDistribution, tf.Tensor), representing the joint distribution
        above, and the posterior variance.
      """
      seeds = samplers.split_seed(seed, 6)
      x_mean = samplers.normal((x_dim,), seed=seeds[0])
      x_scale_diag = samplers.normal((x_dim,), seed=seeds[1])
      y_scale_diag = samplers.normal((y_dim,), seed=seeds[2])
      scale_mat = samplers.normal((y_dim, x_dim), seed=seeds[3])
      y_shift = samplers.normal((y_dim,), seed=seeds[4])
  
      @jdc.JointDistributionCoroutine
      def model():
          x = yield Root(
              mvn_diag.MultivariateNormalDiag(
                  x_mean, scale_diag=x_scale_diag, name="x"
              )
          )
          yield mvn_diag.MultivariateNormalDiag(
              tf.linalg.matvec(scale_mat, x) + y_shift,
              scale_diag=y_scale_diag,
              name="y",
          )
  
      dists, _ = model.sample_distributions(seed=seeds[5])
      precision_x = tf.linalg.inv(dists.x.covariance())
      precision_y = tf.linalg.inv(dists.y.covariance())
      true_cov = tf.linalg.inv(
          precision_x
          + tf.linalg.matmul(
              tf.linalg.matmul(
                  scale_mat, precision_y, transpose_a=True
              ),
              scale_mat,
          )
      )
      return model, tf.linalg.diag_part(true_cov)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import pad
  from tensorflow_probability.python.distributions import autoregressive
  from tensorflow_probability.python.distributions import beta_binomial
  from tensorflow_probability.python.distributions import dirichlet
  from tensorflow_probability.python.distributions import half_normal
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import joint_distribution_coroutine
  from tensorflow_probability.python.distributions import joint_distribution_named
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import multinomial
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import sample
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.experimental import distribute
  from tensorflow_probability.python.experimental.mcmc import windowed_sampling
  from tensorflow_probability.python.internal import callable_util
  from tensorflow_probability.python.internal import distribute_test_lib
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import unnest
  from tensorflow_probability.python.mcmc import diagnostic
label_desc: Use image node_id 5 for calling a global function with example usage: _gen_gaussian_updating_example(x_dim, y_dim, seed) and returns: model,  tf