code: def _test_normal_normal(self, default, dtype):
      with self.test_session() as sess:
          x_data = np.array([0.0] * 50, dtype=np.float32)
  
          mu = Normal(
              loc=tf.constant(0.0, dtype=dtype),
              scale=tf.constant(1.0, dtype=dtype),
          )
          x = Normal(
              loc=mu,
              scale=tf.constant(1.0, dtype=dtype),
              sample_shape=50,
          )
  
          n_samples = 2000
          # analytic solution: N(loc=0.0, scale=\sqrt{1/51}=0.140)
          if not default:
              qmu = Empirical(
                  params=tf.Variable(tf.ones(n_samples, dtype=dtype))
              )
              inference = ed.MetropolisHastings(
                  {mu: qmu}, {mu: mu}, data={x: x_data}
              )
          else:
              inference = ed.MetropolisHastings(
                  [mu], {mu: mu}, data={x: x_data}
              )
              qmu = inference.latent_vars[mu]
          inference.run()
  
          self.assertAllClose(
              qmu.mean().eval(), 0, rtol=1e-1, atol=1e-1
          )
          self.assertAllClose(
              qmu.stddev().eval(), np.sqrt(1 / 51), rtol=1e-1, atol=1e-1
          )
  
          old_t, old_n_accept = sess.run(
              [inference.t, inference.n_accept]
          )
          if not default:
              self.assertEqual(old_t, n_samples)
          else:
              self.assertEqual(old_t, 1e4)
          self.assertGreater(old_n_accept, 0.1)
          sess.run(inference.reset)
          new_t, new_n_accept = sess.run(
              [inference.t, inference.n_accept]
          )
          self.assertEqual(new_t, 0)
          self.assertEqual(new_n_accept, 0)
  
file_path: edward/tests/inferences/metropolishastings_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 Normal, Empirical
label_desc: Use image node_id 1 for calling the test_metropolishastings_class obj's underlying member method code with example usage: obj._test_normal_normal(default, dtype) without return types