src/transformers/models/wavlm/modeling_wavlm.py/WavLMGumbelVectorQuantizer/_compute_perplexity
class WavLMGumbelVectorQuantizer:    def _compute_perplexity(probs):
        marginal_probs = probs.mean(dim=0)
        perplexity = torch.exp(-torch.sum(marginal_probs * torch.log(marginal_probs + 1e-7), dim=-1)).sum()
        return perplexity