src/transformers/models/unispeech_sat/modeling_unispeech_sat.py/UniSpeechSatGumbelVectorQuantizer/_compute_perplexity
class UniSpeechSatGumbelVectorQuantizer:    def _compute_perplexity(probs, mask=None):
        marginal_probs = probs.mean(dim=0)
        perplexity = torch.exp(-torch.sum(marginal_probs * torch.log(marginal_probs + 1e-7), dim=-1)).sum()
        return perplexity