code: def testParametersToAndFromDict(self, tensors_only):
      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)
  
      p_dict = utils.parameters_to_dict(p, tensors_only=tensors_only)
  
      if tensors_only:
          expected_p_dict = {
              "bijector": {"scale": {"matrix": scale_matrix}},
              "distribution": {},
          }
      else:
          expected_p_dict = {
              "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,
              },
          }
  
      tf.nest.map_structure(
          self.assertAllEqual, p_dict, expected_p_dict
      )
  
      # This converts the tf.Variable entry in the matrix to a tf.Tensor
      p_dict["bijector"]["scale"]["matrix"] = (
          p_dict["bijector"]["scale"]["matrix"] + 1.0
      )
  
      # When tensors_only=True, we make sure that we can merge into p
      # from a dict where we dropped everything but tensors.
      p_recreated = utils.merge_to_parameters_from_dict(p, p_dict)
  
      self.assertAllClose(
          p_recreated.params["bijector"]
          .params["scale"]
          .params["matrix"],
          p.params["bijector"].params["scale"].params["matrix"] + 1.0,
      )
  
      # Skip the tensor value comparison -- we checked it above.
      self.compare_params(p, p_recreated, skip_tensor_values=True)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.distributions import utils
  from tf_agents.specs import tensor_spec
label_desc: Use image node_id 7 for calling the UtilsTest obj's underlying member method code with example usage: obj.testParametersToAndFromDict(tensors_only) without return types