code: def _compute_observation_log_weights(
      step,
      particles,
      observations,
      observation_fn,
      num_transitions_per_observation=1,
      particles_dim=0,
  ):
      """Computes particle importance weights from an observation step.
  
      Args:
        step: int `Tensor` current step.
        particles: Nested structure of `Tensor`s, each of shape
          `concat([[num_particles, b1, ..., bN], event_shape])`, where
          `b1, ..., bN` are optional batch dimensions and `event_shape` may
          differ across `Tensor`s.
        observations: Nested structure of `Tensor`s, each of shape
          `concat([[num_observations, b1, ..., bN], event_shape])`
          where `b1, ..., bN` are optional batch dimensions and `event_shape` may
          differ across `Tensor`s.
        observation_fn: callable with signature
          `observation_dist = observation_fn(step, particles)`, producing
          a batch of distributions over the `observation` at the given `step`,
          one for each particle.
        num_transitions_per_observation: optional int `Tensor` number of times
          to apply the transition model between successive observation steps.
          Default value: `1`.
        particles_dim: `int` dimension that indexes the particles in `particles`.
          Default value: `0`.
      Returns:
        log_weights: `Tensor` of shape `concat([num_particles, b1, ..., bN])`.
      """
      with tf.name_scope("compute_observation_log_weights"):
          step_has_observation = (
              # The second of these conditions subsumes the first, but both are
              # useful because the first can often be evaluated statically.
              ps.equal(num_transitions_per_observation, 1)
              | ps.equal(step % num_transitions_per_observation, 0)
          )
          observation_idx = step // num_transitions_per_observation
          observation = tf.nest.map_structure(
              lambda x, step=step: tf.gather(x, observation_idx),
              observations,
          )
  
          observation = tf.nest.map_structure(
              lambda x: tf.expand_dims(x, axis=particles_dim),
              observation,
          )
  
          log_weights = observation_fn(step, particles).log_prob(
              observation
          )
          return tf.where(
              step_has_observation,
              log_weights,
              tf.zeros_like(log_weights),
          )
  
file_path: probability/tensorflow_probability/python/experimental/mcmc/particle_filter.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import sequential_monte_carlo_kernel
  from tensorflow_probability.python.experimental.mcmc import weighted_resampling
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import docstring_util
  from tensorflow_probability.python.internal import loop_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.mcmc.internal import util
label_desc: Use image node_id 7 for calling a global function with example usage: _compute_observation_log_weights(step, particles, observations, observation_fn, num_transitions_per_observation, particles_dim) and returns: tf