def quantize(samples, bits=8, epsilon=0.01):
    """
    Linearly quantize a signal in [0, 1] to a signal in [0, q_levels - 1].
    """
    q_levels = 1 << bits
    samples *= q_levels - epsilon
    samples += epsilon / 2
    return samples.long()

    Linearly quantize a signal in [0, 1] to a signal in [0, q_levels - 1].
    
analyze/convnexts4nd/src/dataloaders/audio.py