code: def test_estimated_prob_approximates_true_prob(self):
      # Draw simulated data from a 2D linear Gaussian system.
      initial_state_prior = mvn_diag.MultivariateNormalDiag(
          loc=0.0, scale_diag=(1.0, 1.0)
      )
      transition_matrix = tf.convert_to_tensor(
          [[1.0, -0.5], [0.4, -1.0]]
      )
      transition_noise = mvn_tril.MultivariateNormalTriL(
          loc=1.0,
          scale_tril=tf.convert_to_tensor([[0.3, 0], [-0.1, 0.2]]),
      )
      observation_matrix = tf.convert_to_tensor(
          [[0.1, 1.0], [1.0, 0.2]]
      )
      observation_noise = mvn_tril.MultivariateNormalTriL(
          loc=-0.3,
          scale_tril=tf.convert_to_tensor([[0.5, 0], [0.1, 0.5]]),
      )
      model = lgssm.LinearGaussianStateSpaceModel(
          num_timesteps=20,
          initial_state_prior=initial_state_prior,
          transition_matrix=transition_matrix,
          transition_noise=transition_noise,
          observation_matrix=observation_matrix,
          observation_noise=observation_noise,
      )
      observations = self.evaluate(
          model.sample(seed=test_util.test_seed())
      )
      (lps, filtered_means, _, _, _, _, _) = self.evaluate(
          model.forward_filter(observations)
      )
  
      # Approximate the filtering means and marginal likelihood(s) using
      # the particle filter.
      # pylint: disable=g-long-lambda
      (
          particles,
          log_weights,
          _,
          estimated_incremental_log_marginal_likelihoods,
      ) = self.evaluate(
          particle_filter.particle_filter(
              observations=observations,
              initial_state_prior=initial_state_prior,
              transition_fn=lambda _, previous_state: mvn_tril.MultivariateNormalTriL(
                  loc=transition_noise.loc
                  + tf.linalg.matvec(transition_matrix, previous_state),
                  scale_tril=transition_noise.scale_tril,
              ),
              observation_fn=lambda _, state: mvn_tril.MultivariateNormalTriL(
                  loc=observation_noise.loc
                  + tf.linalg.matvec(observation_matrix, state),
                  scale_tril=observation_noise.scale_tril,
              ),
              num_particles=1024,
              seed=test_util.test_seed(),
          )
      )
      # pylint: enable=g-long-lambda
  
      particle_means = np.sum(
          particles * np.exp(log_weights)[..., np.newaxis], axis=1
      )
      self.assertAllClose(
          filtered_means, particle_means, atol=0.1, rtol=0.1
      )
  
      self.assertAllClose(
          lps, estimated_incremental_log_marginal_likelihoods, atol=0.6
      )
  
imports: import functools
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import shift
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import deterministic
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import joint_distribution_named
  from tensorflow_probability.python.distributions import linear_gaussian_ssm
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import mvn_tril
  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 transformed_distribution
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.experimental.mcmc import particle_filter
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 7 for calling the _ParticleFilterTest obj's underlying member method code with example usage: obj.test_estimated_prob_approximates_true_prob() without return types