code: def testConditionFn(self, static_length):
      final_state, trace = self.evaluate(
          loop_util.trace_scan(
              loop_fn=lambda state, element: state + element,
              initial_state=0,
              elems=[1, 2, 3, 4, 5, 6, 7],
              trace_fn=lambda state: state / 2,
              condition_fn=lambda step, state, num_traced, trace: state
              < 9,
              static_trace_allocation_size=4 if static_length else None,
          )
      )
      self.assertAllClose(10, final_state)
      self.assertAllClose([0.5, 1.5, 3, 5], trace)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import auto_composite_tensor
  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.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 4 for calling the TraceScanTest obj's underlying member method code with example usage: obj.testConditionFn(static_length) without return types