def rand_gumbel(shape):
    """Sample from the Gumbel distribution, protect from overflows."""
    uniform_samples = torch.rand(shape) * 0.99998 + 0.00001
    return -torch.log(-torch.log(uniform_samples))
Sample from the Gumbel distribution, protect from overflows.
models/codec/facodec/modules/commons.py