code: def test_bitstring_length_matches_estimates(self, training, prior):
      priors = {
          "deep_factorized": deep_factorized.NoisyDeepFactorized(
              batch_shape=(16,)
          ),
          "normal": uniform_noise.NoisyNormal(
              loc=tf.range(16.0), scale=1.0
          ),
      }
      prior = priors[prior]
      em = universal.UniversalBatchedEntropyModel(
          prior, coding_rank=2, compression=True
      )
      num_symbols = 1000
      # Source distribution is fixed as gaussian.
      source = priors["normal"].base
      x = source.sample((3, num_symbols), seed=0)
      x_perturbed, bits_estimate = em(x, training=training)
      bitstring = em.compress(x)
      x_decoded = em.decompress(bitstring, (num_symbols,))
      bitstring_bits = tf.reshape(
          [len(b) * 8 for b in bitstring.numpy().flatten()],
          bitstring.shape,
      )
      # Max error 1% and 2 bytes.
      self.assertAllClose(
          bits_estimate, bitstring_bits, atol=16, 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 2 for calling the UniversalBatchedEntropyModelTest obj's underlying member method code with example usage: obj.test_bitstring_length_matches_estimates(training, prior) without return types