code: def _get_yielded_and_returned_values(gen, values_to_send=()):
      """Helper for testing generators and coroutines."""
      yvals = []
      try:
          yvals.append(next(gen))
          for s in values_to_send:
              yvals.append(gen.send(s))
          while (
              True
          ):  # Loop until `gen` returns, even if no more values to send.
              yvals.append(next(gen))
      except StopIteration as e:
          rvals = e.value
      return yvals, rvals
  
imports: import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import deterministic
  from tensorflow_probability.python.distributions import half_cauchy
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling a global function with example usage: _get_yielded_and_returned_values(gen, values_to_send) and returns: yvals,  rvals