code: def _test_linear_regression(self, default, dtype):
      def build_toy_dataset(N, w, noise_std=0.1):
          D = len(w)
          x = np.random.randn(N, D)
          y = np.dot(x, w) + np.random.normal(0, noise_std, size=N)
          return x, y
  
      with self.test_session() as sess:
          N = 40  # number of data points
          D = 10  # number of features
  
          w_true = np.random.randn(D)
          X_train, y_train = build_toy_dataset(N, w_true)
          X_test, y_test = build_toy_dataset(N, w_true)
  
          X = tf.placeholder(dtype, [N, D])
          w = Normal(
              loc=tf.zeros(D, dtype=dtype),
              scale=tf.ones(D, dtype=dtype),
          )
          b = Normal(
              loc=tf.zeros(1, dtype=dtype),
              scale=tf.ones(1, dtype=dtype),
          )
          y = Normal(
              loc=ed.dot(X, w) + b, scale=0.1 * tf.ones(N, dtype=dtype)
          )
  
          n_samples = 2000
          if not default:
              qw = Empirical(
                  tf.Variable(tf.zeros([n_samples, D], dtype=dtype))
              )
              qb = Empirical(
                  tf.Variable(tf.zeros([n_samples, 1], dtype=dtype))
              )
              inference = ed.HMC(
                  {w: qw, b: qb}, data={X: X_train, y: y_train}
              )
          else:
              inference = ed.HMC([w, b], data={X: X_train, y: y_train})
              qw = inference.latent_vars[w]
              qb = inference.latent_vars[b]
          inference.run(step_size=0.01)
  
          self.assertAllClose(
              qw.mean().eval(), w_true, rtol=5e-1, atol=5e-1
          )
          self.assertAllClose(
              qb.mean().eval(), [0.0], rtol=5e-1, atol=5e-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/hmc_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 Categorical, Empirical, Normal
label_desc: Use image node_id 2 for calling the test_hmc_class obj's underlying member method code with example usage: obj._test_linear_regression(default, dtype) and returns: x,  y