code: def test_bitstring_length_matches_estimates(self, training):
      em = universal.UniversalIndexedEntropyModel(
          prior_fn=uniform_noise.NoisyNormal,
          index_ranges=(10, 10),
          parameter_fns=dict(
              loc=lambda i: (i[..., 0] - 5.0) / 10.0,
              scale=lambda i: tf.exp(-i[..., 1]),
          ),
          coding_rank=1,
          compression=True,
      )
      self.assertEqual(em.coding_rank, 1)
      self.assertEqual(em._laplace_tail_mass, 0.0)
      self.assertEqual(em.tail_mass, 2**-8)
      self.assertEqual(em.range_coder_precision, 12)
      num_symbols = 1000
      # Source distribution is gaussian with stddev 1.
      x = tf.random.stateless_normal((1, 1, num_symbols), seed=(0, 0))
      # We predict the distribution correctly (mean = 5-5=0, scale = exp(0)=1.
      indexes = tf.concat(
          (
              5 * tf.ones((1, 1, num_symbols, 1)),
              0 * tf.ones((1, 1, num_symbols, 1)),
          ),
          axis=-1,
      )
      x_perturbed, bits_estimate = em(x, indexes, training=training)
      bitstring = em.compress(x, indexes)
      x_decoded = em.decompress(bitstring, indexes)
      bitstring_bits = tf.reshape(
          [len(b) * 8 for b in bitstring.numpy().flatten()],
          bitstring.shape,
      )
      # Max error 1% and 1 byte.
      self.assertAllClose(
          bits_estimate, bitstring_bits, atol=8, rtol=0.01
      )
      # Quantization noise should be between -.5 and .5
      self.assertAllLessEqual(tf.abs(x - x_decoded), 0.5)
      self.assertAllLessEqual(tf.abs(x - x_perturbed), 0.5)
  
imports: from absl.testing import parameterized
  import scipy.stats
  import tensorflow
  import tensorflow_probability
  from tensorflow_compression.python.distributions import deep_factorized
  from tensorflow_compression.python.distributions import uniform_noise
  from tensorflow_compression.python.entropy_models import universal
label_desc: Use image node_id 5 for calling the UniversalIndexedEntropyModelTest obj's underlying member method code with example usage: obj.test_bitstring_length_matches_estimates(training) without return types