code: def test_random_walk(self):
      initial_state_prior = jdn.JointDistributionNamed(
          {"position": deterministic.Deterministic(0.0)}
      )
  
      # Biased random walk.
      def particle_dynamics(_, previous_state):
          state_shape = ps.shape(previous_state["position"])
          return jdn.JointDistributionNamed(
              {
                  "position": transformed_distribution.TransformedDistribution(
                      bernoulli.Bernoulli(
                          probs=tf.fill(state_shape, 0.75),
                          dtype=self.dtype,
                      ),
                      shift.Shift(previous_state["position"]),
                  )
              }
          )
  
      # Completely uninformative observations allowing a test
      # of the pure dynamics.
      def particle_observations(_, state):
          state_shape = ps.shape(state["position"])
          return uniform.Uniform(
              low=tf.fill(state_shape, -100.0),
              high=tf.fill(state_shape, 100.0),
          )
  
      observations = tf.zeros((9,), dtype=self.dtype)
      trajectories, _ = self.evaluate(
          particle_filter.infer_trajectories(
              observations=observations,
              initial_state_prior=initial_state_prior,
              transition_fn=particle_dynamics,
              observation_fn=particle_observations,
              num_particles=16384,
              seed=test_util.test_seed(),
          )
      )
      position = trajectories["position"]
  
      # The trajectories have the following properties:
      # 1. they lie completely in the range [0, 8]
      self.assertAllInRange(position, 0.0, 8.0)
      # 2. each step lies in the range [0, 1]
      self.assertAllInRange(position[1:] - position[:-1], 0.0, 1.0)
      # 3. the expectation and variance of the final positions are 6 and 1.5.
      self.assertAllClose(tf.reduce_mean(position[-1]), 6.0, atol=0.1)
      self.assertAllClose(
          tf.math.reduce_variance(position[-1]), 1.5, atol=0.1
      )
  
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 1 for calling the _ParticleFilterTest obj's underlying member method code with example usage: obj.test_random_walk() and returns: jdn, uniform