code: def ess_below_threshold(
      weighted_particles, particles_dim=0, threshold=0.5
  ):
      """Determines if the effective sample size is much less than num_particles."""
      with tf.name_scope("ess_below_threshold"):
          num_particles = ps.size0(weighted_particles.log_weights)
          log_ess = log_ess_from_log_weights(
              weighted_particles.log_weights,
              particles_dim=particles_dim,
          )
          return tf.expand_dims(
              log_ess < (ps.log(num_particles) + ps.log(threshold)),
              axis=particles_dim,
          )
  
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import weighted_resampling
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.mcmc import kernel
  from tensorflow_probability.python.mcmc.internal import util
label_desc: Use image node_id 3 for calling a global function with example usage: ess_below_threshold(weighted_particles, particles_dim, threshold) and returns: tf