code: def test_auto_transform_true(self):
      with self.test_session() as sess:
          # Match normal || softplus-inverse-normal distribution with
          # automated transformation on latter (assuming it is softplus).
          x = TransformedDistribution(
              distribution=Normal(0.0, 0.5),
              bijector=tf.contrib.distributions.bijectors.Softplus(),
          )
          x.support = "nonnegative"
          qx = Normal(
              loc=tf.Variable(tf.random_normal([])),
              scale=tf.nn.softplus(tf.Variable(tf.random_normal([]))),
          )
  
          inference = ed.KLqp({x: qx})
          inference.initialize(
              auto_transform=True, n_samples=5, n_iter=1000
          )
          tf.global_variables_initializer().run()
          for _ in range(inference.n_iter):
              info_dict = inference.update()
  
          # Check approximation on constrained space has same moments as
          # target distribution.
          n_samples = 10000
          x_mean, x_var = tf.nn.moments(x.sample(n_samples), 0)
          x_unconstrained = inference.transformations[x]
          qx_constrained = transform(
              qx, bijectors.Invert(x_unconstrained.bijector)
          )
          qx_mean, qx_var = tf.nn.moments(
              qx_constrained.sample(n_samples), 0
          )
          stats = sess.run([x_mean, qx_mean, x_var, qx_var])
          self.assertAllClose(
              info_dict["loss"], 0.0, rtol=0.2, atol=0.2
          )
          self.assertAllClose(stats[0], stats[1], rtol=1e-1, atol=1e-1)
          self.assertAllClose(stats[2], stats[3], rtol=1e-1, atol=1e-1)
  
file_path: edward/tests/inferences/inference_auto_transform_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import edward
  import numpy
  import tensorflow
  from edward.models import Empirical, Gamma, Normal, PointMass, TransformedDistribution, Beta, Bernoulli
  from edward.util import transform
  from tensorflow.contrib.distributions import bijectors
label_desc: Use image node_id 1 for calling the test_inference_auto_transform_class obj's underlying member method code with example usage: obj.test_auto_transform_true() without return types