code: def _choose_recursive(
      is_accepted, proposed, current, name=None, addr="<root>"
  ):
      """Recursion helper which also reports the address of any failures."""
      with tf.name_scope(name or "choose"):
          if not is_namedtuple_like(proposed):
              return _choose_base_case(
                  is_accepted, proposed, current, name=name, addr=addr
              )
          if not isinstance(proposed, type(current)):
              raise TypeError(
                  f"Type of `proposed` ({type(proposed).__name__}) must be identical "
                  f'to type of `current` ({type(current).__name__}). (At "{addr}".)'
              )
          items = {}
          for fn in proposed._fields:
              items[fn] = _choose_recursive(
                  is_accepted,
                  getattr(proposed, fn),
                  getattr(current, fn),
                  name=name,
                  addr=f"{addr}/{fn}",
              )
          return type(proposed)(**items)
  
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 6 for calling a global function with example usage: _choose_recursive(is_accepted, proposed, current, name, addr) and returns: type, _choose_base_case