import tensorflow as tf

        x = np.arange(-100, 100, 2).astype(dtype)

        tf.initialize_all_variables().run()

        proba = qdist.log_prob(x)
        grads = tf.gradients(proba, [mu, sigma])

        self._assert_all_finite(proba.eval())
        self._assert_all_finite(grads[0].eval())
        self._assert_all_finite(grads[1].eval())

  def test_prob_and_grad_gives_finite_results_for_common_events(self):
    with self.test_session():
      mu = tf.Variable(0.0, name="mu")
      sigma = tf.Variable(1.0, name="sigma")
      qdist = distributions.QuantizedDistribution(
          base_dist_cls=distributions.Normal,
          mu=mu,
          sigma=sigma)
      x = tf.ceil(4 * self._rng.rand(100).astype(np.float32) - 2)

      tf.initialize_all_variables().run()

      proba = qdist.prob(x)
      self._assert_all_finite(proba.eval())

