code: def choose_from(n, options):
      """Helper to select the n-th option from a list of options.
  
      This is useful when `n` is not a concrete value. Also note that
      the value of `n` will be clipped to the edges of the interval
      `[0, len(options) - 1]`.
  
      Args:
        n: Scalar `int` `Tensor` option.
        options: List of options to choose from. All the options should have the
          same nested structure.
  
      Returns:
        The n-th option among `options`.
      """
      if len(options) == 1:
          return options[0]
      m = len(options) // 2
      return _nest_choose(
          n < m,
          choose_from(n, options[:m]),
          choose_from(n - m, options[m:]),
      )
  
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 9 for calling a global function with example usage: choose_from(n, options) and returns: _nest_choose, options