code: def _initialize_parameters(generator, seed=None):
      """Samples initial values for all parameters yielded by a generator.
  
      Args:
        generator: Python generator that yields initialization callables
          (which take a `seed` and return a (structure of) `Tensor`(s)),
          returns a value, and has no side effects. See module description.
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
      Returns:
        raw_parameters: Python list of `Tensor` (or structure of `Tensor`s) initial
          parameter values returned from the yielded callables.
      """
      gen = generator()
      if not isinstance(gen, types.GeneratorType):
          raise ValueError(
              "Expected generator but saw function: {}. A generator "
              "must contain at least one `yield` statement. To define a "
              "trivial generator, which yields zero times, a `yield` "
              "statement may be placed after `return`, but must still "
              "be present.".format(generator)
          )
  
      raw_parameters = []
      parameter_names = []
      param_value = None
      try:
          while True:
              parameter = gen.send(param_value)
              if not hasattr(parameter, "init_fn"):
                  raise ValueError(
                      "Expected generator to yield a "
                      "trainable_state_util.Parameter namedtuple, but saw "
                      "{} instead.".format(parameter)
                  )
              seed, local_seed = samplers.split_seed(seed, n=2)
              # Note: this framework guarantees that the `init_fn` is only ever called
              # here, immediately after being yielded before control is returned
              # to the coroutine. This allows the coroutine to safely incorporate
              # loop-dependent state in the closure of `init_fn` if desired.
              param_value = _call_init_fn(
                  parameter.init_fn, seed=local_seed
              )
              raw_value = (
                  param_value
                  if parameter.constraining_bijector is None
                  else parameter.constraining_bijector.inverse(
                      param_value
                  )
              )
              raw_parameters.append(raw_value)
              parameter_names.append(
                  _get_unused_parameter_name(
                      parameter.name or "parameter", parameter_names
                  )
              )
      except StopIteration:
          pass
      return structural_tuple.structtuple(parameter_names)(
          *raw_parameters
      )
  
file_path: probability/tensorflow_probability/python/internal/trainable_state_util.py
imports: import collections
  import functools
  import inspect
  import re
  import types
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import structural_tuple
label_desc: Use image node_id 3 for calling a global function with example usage: _initialize_parameters(generator, seed) and returns: structural_tuple