code: def _choose_base_case(
      is_accepted,
      proposed,
      current,
      name=None,
      addr=None,
  ):
      """Helper to `choose` which expand_dims `is_accepted` and applies tf.where."""
  
      def _where(proposed, current):
          """Wraps `tf.where`."""
          if proposed is current:
              return proposed
  
          # Handle CompositeTensor types at the leafmost `addr`.
          flat_p = tf.nest.flatten(proposed, expand_composites=True)
          flat_c = tf.nest.flatten(current, expand_composites=True)
  
          res = []
          for p, c in zip(flat_p, flat_c):
              # Preserve the name from `current` so names can propagate from
              # `bootstrap_results`.
              name = getattr(c, "name", None)
              if name is not None:
                  name = name.rpartition("/")[2].rsplit(":", 1)[0]
              # Since this is an internal utility it is ok to assume
              # tf.shape(proposed) == tf.shape(current).
              res.append(
                  tf.where(
                      bu.left_justified_expand_dims_like(
                          is_accepted, p
                      ),
                      p,
                      c,
                      name=name,
                  )
              )
          return tf.nest.pack_sequence_as(
              current, res, expand_composites=True
          )
  
      with tf.name_scope(name or "choose"):
          if not is_list_like(proposed):
              return _where(proposed, current)
          return tf.nest.pack_sequence_as(
              current,
              [
                  (
                      _choose_recursive(
                          is_accepted,
                          p,
                          c,
                          name=name,
                          addr=f"{addr}[i]",
                      )
                      if is_namedtuple_like(p)
                      else _where(p, c)
                  )
                  for i, (p, c) in enumerate(zip(proposed, current))
              ],
          )
  
imports: import warnings
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import broadcast_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math.gradient import value_and_gradient
  from tensorflow.python.util import deprecation
label_desc: Use image node_id 5 for calling a global function with example usage: _choose_base_case(is_accepted, proposed, current, name, addr) and returns: tf, tf, proposed, _where