code: def parameters_to_dict(
      value: Params, tensors_only: bool = False
  ) -> Mapping[Text, Any]:
      """Converts `value` to a nested `dict` (excluding all `type_` info).
  
      Sub-dicts represent `Params` objects; keys represent flattened nest structures
      in `value.params`.
  
      Example:
  
      ```python
      scale_matrix = tf.Variable([[1.0, 2.0], [-1.0, 0.0]])
      d = tfp.distributions.MultivariateNormalDiag(
          loc=[1.0, 1.0], scale_diag=[2.0, 3.0], validate_args=True)
      b = tfp.bijectors.ScaleMatvecLinearOperator(
          scale=tf.linalg.LinearOperatorFullMatrix(matrix=scale_matrix),
          adjoint=True)
      b_d = b(d)
      p = utils.get_parameters(b_d)
      params_dict = utils.parameters_to_dict(p, tensors_only)
      ```
  
      results in the nested dictionary, if `tensors_only=False`:
  
      ```python
      {
        "bijector": {"adjoint": True,
                     "scale": {"matrix": scale_matrix}},
        "distribution": {"validate_args": True,
                         # These are deeply nested because we passed lists
                         # intead of numpy arrays for `loc` and `scale_diag`.
                         "scale_diag:0": 2.0,
                         "scale_diag:1": 3.0,
                         "loc:0": 1.0,
                         "loc:1": 1.0}
      }
      ```
  
      results if `tensors_only=True`:
  
      ```python
      {
        "bijector": {"scale": {"matrix": scale_matrix}},
        "distribution": {},
      }
      ```
  
      The dictionary may then be modified or updated (e.g., in place), and converted
      back to a `Params` object using `merge_to_parameters_from_dict`.
  
      Args:
        value: The (possibly recursively defined) `Params`.
        tensors_only: Whether to include all parameters or only tensors and
          TypeSpecs.  If `True`, then only `tf.Tensor` and `tf.TypeSpec` leaf
          parameters are emitted.
  
      Returns:
        A `dict` mapping `value.params` to flattened key/value pairs.  Any
        sub-`Params` objects become nested dicts.
      """
      output_entries = {}
  
      # All tensors and TensorSpecs will be included for purposes of this test.
      is_tensor_or_spec = lambda p: tf.is_tensor(p) or isinstance(
          p, tf.TypeSpec
      )
  
      def convert(key, p):
          if isinstance(p, Params):
              output_entries[key] = parameters_to_dict(p, tensors_only)
          elif not tensors_only or is_tensor_or_spec(p):
              output_entries[key] = p
  
      for k, v in value.params.items():
          if tf.nest.is_nested(v):
              flattened_params = nest_utils.flatten_with_joined_paths(v)
              for param_k, param_v in flattened_params:
                  key = "{}:{}".format(k, param_k)
                  convert(key, param_v)
          else:
              convert(k, v)
  
      return output_entries
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  from typing import Any, Mapping, Text, Type
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.distributions import tanh_bijector_stable
  from tf_agents.specs import tensor_spec
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 4 for calling a global function with example usage: parameters_to_dict(value, tensors_only) and returns: output_entries