Useful compute_metrics functions for perplexity

I have trained a custom bert-base Transformer for MLM, and want to report the perplexity (opposed to eval_loss) after each eval_step. I have tried various different compute_metrics functions to no avail. Any ideas?