code: def test_conserves_partial_shapes(self):
      # Testing that `choose` correctly propagates shape information about the
      # arms, even when those shapes are partial and when the shape of the
      # condition is partial as well.
      input_signature = [tf.TensorSpec([], tf.int32)]
  
      @tf.function(input_signature=input_signature)
      def try_me(batch_size):
          # The while loop is necessary for this test, because it affects TF's shape
          # inference behavior somehow (maybe another appearance of b/139013403?).
          init = tf.zeros([batch_size, 1])
  
          def body_fn(state):
              arm_1 = state
              arm_2 = tf.ones([batch_size, 1])
              condition = tf.ones([batch_size], dtype=tf.bool)
              result = util.choose(condition, arm_1, arm_2)
              # The test is the automatic check inside `tf.while_loop` that the static
              # shape returned here is the same as the static shape of the input
              # `state`.
              return result
  
          tf.while_loop(
              cond=lambda *_: False, body=body_fn, loop_vars=(init,)
          )
  
      try_me(5)
  
imports: import collections
  import warnings
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.mcmc.internal import util
label_desc: Use image node_id 3 for calling the ChooseTest obj's underlying member method code with example usage: obj.test_conserves_partial_shapes() and returns: result