code: def mid_elements(
      transition_matrix,
      transition_cov,
      observation_matrix,
      observation_cov,
      transition_mean,
      observation_mean,
      y,
  ):
      """Represents messages from observed values at non-initial timesteps."""
      # The naming of these variables has been chosen for consistency with
      # p.4 of Temporal Parallelization of Bayesian Smoothers
      # https://arxiv.org/abs/1905.13002
      with tf.name_scope("mid_elements"):
          pushforward_cov = _propagate_cov(
              matrix=observation_matrix,
              cov=transition_cov,
              added_cov=observation_cov,
          )
          chol_pushforward_cov = tf.linalg.cholesky(pushforward_cov)
          inv_pushforward_cov_yhat = linalg.hpsd_solvevec(
              pushforward_cov,
              y
              - (
                  _propagate_mean(
                      matrix=observation_matrix,
                      mean=transition_mean,
                      added_mean=observation_mean,
                  )
              ),
              cholesky_matrix=chol_pushforward_cov,
          )
          conjugated_pushforward_cov = linalg.hpsd_quadratic_form_solve(
              pushforward_cov,
              observation_matrix,
              cholesky_matrix=chol_pushforward_cov,
          )
  
          tmp = _add_identity_to_diagonal(
              -tf.linalg.matmul(
                  transition_cov, conjugated_pushforward_cov
              )
          )
          obs_matrix_trans_matrix = tf.linalg.matmul(
              observation_matrix, transition_matrix
          )
  
          transition_cov_obs_matrix_transpose = tf.linalg.matmul(
              transition_cov, observation_matrix, transpose_b=True
          )
  
          return FilterElements(
              posterior_link_matrix=tf.linalg.matmul(
                  tmp, transition_matrix
              ),
              posterior_mean=tf.linalg.matvec(
                  transition_cov_obs_matrix_transpose,
                  inv_pushforward_cov_yhat,
              )
              + transition_mean,
              posterior_cov=tf.linalg.matmul(tmp, transition_cov),
              marginal_likelihood_meanprec=tf.linalg.matvec(
                  obs_matrix_trans_matrix,
                  inv_pushforward_cov_yhat,
                  transpose_a=True,
              ),
              marginal_likelihood_prec=linalg.hpsd_quadratic_form_solve(
                  pushforward_cov,
                  obs_matrix_trans_matrix,
                  cholesky_matrix=chol_pushforward_cov,
              ),
          )
  
imports: import collections
  import functools
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.math import linalg
  from tensorflow_probability.python.math.scan_associative import scan_associative
label_desc: Use image node_id 7 for calling a global function with example usage: mid_elements(transition_matrix, transition_cov, observation_matrix, observation_cov, transition_mean, observation_mean, y) and returns: FilterElements