code: def test_penalty_is_proportional_to_code_length(self):
      em = PowerLawEntropyModel(coding_rank=1)
      x = tf.range(-20.0, 20.0)[:, None]
      x += tf.random.uniform(x.shape, -0.49, 0.49)
      strings = em.compress(tf.broadcast_to(x, (40, 100)))
      code_lengths = tf.cast(
          tf.strings.length(strings, unit="BYTE"), tf.float32
      )
      code_lengths *= 8 / 100
      penalties = em.penalty(x)
      # There are some fluctuations due to `alpha`, `floor`, and rounding, but we
      # expect a high degree of correlation between code lengths and penalty.
      self.assertGreater(
          np.corrcoef(code_lengths, penalties)[0, 1], 0.96
      )
  
file_path: compression/tensorflow_compression/python/entropy_models/power_law_test.py
imports: import numpy
  import tensorflow
  from tensorflow_compression.python.entropy_models.power_law import PowerLawEntropyModel
label_desc: Use image node_id 6 for calling the PowerLawEntropyModelTest obj's underlying member method code with example usage: obj.test_penalty_is_proportional_to_code_length() without return types