code: def has_not_u_turn(
      state_diff,
      velocity_left,
      velocity_right,
      log_prob_rank,
      shard_axis_names=None,
  ):
      """If the trajectory does not exhibit a U-turn pattern."""
      shard_axis_names = shard_axis_names or ([None] * len(state_diff))
  
      def reduce_sum(x, v, shard_axes):
          out = tf.reduce_sum(
              x, axis=ps.range(log_prob_rank, ps.rank(v))
          )
          if shard_axes is not None:
              out = distribute_lib.psum(out, shard_axes)
          return out
  
      with tf.name_scope("has_not_u_turn"):
          batch_dot_product_left = sum(
              [
                  reduce_sum(  # pylint: disable=g-complex-comprehension
                      s_diff * v, v, shard_axes
                  )
                  for s_diff, v, shard_axes in zip(
                      state_diff, velocity_left, shard_axis_names
                  )
              ]
          )
          batch_dot_product_right = sum(
              [
                  reduce_sum(  # pylint: disable=g-complex-comprehension
                      s_diff * v, v, shard_axes
                  )
                  for s_diff, v, shard_axes in zip(
                      state_diff, velocity_right, shard_axis_names
                  )
              ]
          )
          return (batch_dot_product_left >= 0) & (
              batch_dot_product_right >= 0
          )
  
imports: import collections
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import preconditioning_utils
  from tensorflow_probability.python.internal import broadcast_util
  from tensorflow_probability.python.internal import distribute_lib
  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.math.generic import log_add_exp
  from tensorflow_probability.python.mcmc.internal import leapfrog_integrator
  from tensorflow_probability.python.mcmc.internal import util
  from tensorflow_probability.python.mcmc.kernel import TransitionKernel
label_desc: Use image node_id 2 for calling a global function with example usage: has_not_u_turn(state_diff, velocity_left, velocity_right, log_prob_rank, shard_axis_names) and returns: out, unknown