code: def test_klqp_betabernoulli(self):
      with self.test_session() as sess:
          # model
          z = Beta(1.0, 1.0, name="z")
          xs = Bernoulli(probs=z, sample_shape=10)
          x_obs = np.asarray(
              [0, 0, 1, 1, 0, 0, 0, 0, 0, 1], dtype=np.int32
          )
  
          # inference
          qz_mean = tf.get_variable(
              "qz_mean", initializer=tf.random_normal(())
          )
          qz_std = tf.nn.softplus(
              tf.get_variable(
                  name="qz_prestd", initializer=tf.random_normal(())
              )
          )
          qz_unconstrained = ed.models.Normal(
              loc=qz_mean, scale=qz_std, name="z_posterior"
          )
  
          inference_klqp = ed.inferences.KLqp(
              {z: qz_unconstrained}, data={xs: x_obs}
          )
          inference_klqp.run(n_iter=500, auto_transform=True)
  
          z_unconstrained = inference_klqp.transformations[z]
          qz_constrained = z_unconstrained.bijector.inverse(
              qz_unconstrained.sample(1000)
          )
          qz_mean, qz_var = sess.run(tf.nn.moments(qz_constrained, 0))
  
          true_posterior = Beta(
              np.sum(x_obs) + 1.0, np.sum(1 - x_obs) + 1.0
          )
          pz_mean, pz_var = sess.run(
              (true_posterior.mean(), true_posterior.variance())
          )
          self.assertAllClose(qz_mean, pz_mean, rtol=5e-2, atol=5e-2)
          self.assertAllClose(qz_var, pz_var, rtol=1e-2, atol=1e-2)
  
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 9 for calling the test_inference_auto_transform_class obj's underlying member method code with example usage: obj.test_klqp_betabernoulli() without return types