code: def freqs_to_cdf(freqs, precision=16):
      # Converts a frequency count to a discretized CDF with values
      # between [0, 2**precision)
      pdf = freqs / freqs.sum(axis=-1, keepdims=True)
      cdf = jnp.append(
          jnp.zeros((*pdf.shape[:-1], 1)), pdf.cumsum(axis=-1), axis=-1
      )
      return jnp.round(cdf * 2**precision).astype(jnp.uint32)
  
file_path: NeuralCompression/projects/jax_entropy_coders/test_entropy_coders.py
imports: import craystack
  import jax.numpy
  import jax_arithmetic_coder
  import numpy
  import pytest
  import scipy
label_desc: Use image node_id 1 for calling a global function with example usage: freqs_to_cdf(freqs, precision) and returns: jnp