code: def testQuantizationOfUniformWithCutoffsInTheMiddle(self):
      # The uniform is supported on [-3, 3]
      # Consider partitions the real line in intervals
      # ...(-3, -2](-2, -1](-1, 0](0, 1](1, 2](2, 3] ...
      # Before cutoffs, the uniform puts a mass of 1/6 in each interval written
      # above.  Because of cutoffs, the qdist considers intervals and indices
      # ...(-infty, -1](-1, 0](0, infty) ...
      #             -1      0     1
      qdist = qd.QuantizedDistribution(
          distribution=uniform.Uniform(low=-3.0, high=3.0),
          low=-1.0,
          high=1.0,
          validate_args=False,
      )
  
      # pmf
      (
          cdf_n3,
          cdf_n2,
          cdf_n1,
          cdf_0,
          cdf_0p5,
          cdf_1,
          cdf_10,
      ) = self.evaluate(
          qdist.cdf([-3.0, -2.0, -1.0, 0.0, 0.5, 1.0, 10.0])
      )
      # Uniform had no mass on (-4, -3] or (-3, -2]
      self.assertAllClose(0.0, cdf_n3)
      self.assertAllClose(0.0, cdf_n2)
      # Uniform had 1/6 of its mass in each of (-3, -2], and (-2, -1], which
      # were collapsed into (-infty, -1], which is now the '-1' interval.
      self.assertAllClose(1 / 3, cdf_n1)
      # The j=0 interval contained mass from (-3, 0], which is 1/2 of the
      # uniform's mass.
      self.assertAllClose(1 / 2, cdf_0)
      # Adding 0.5 makes no difference because the quantized dist has mass on
      # the integers, not in between them.
      self.assertAllClose(1 / 2, cdf_0p5)
      # After applying the cutoff, all mass was either in the interval
      # (0, infty), or below.  (0, infty) is the interval indexed by j=1,
      # so pmf(1) should equal 1.
      self.assertAllClose(1.0, cdf_1)
      # Since no mass of qdist is above 1,
      # pmf(10) = P[Y <= 10] = P[Y <= 1] = pmf(1).
      self.assertAllClose(1.0, cdf_10)
  
imports: import numpy
  from scipy import stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import logistic
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import quantized_distribution
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 2 for calling the QuantizedDistributionTest obj's underlying member method code with example usage: obj.testQuantizationOfUniformWithCutoffsInTheMiddle() without return types