    def get_metric(self, reset: bool = False):
        """
        # Returns

        The accumulated perplexity.
        """
        average_loss = super().get_metric(reset)
        if average_loss == 0:
            return 0.0

        # Exponentiate the loss to compute perplexity
        return math.exp(average_loss)
# Returns

The accumulated perplexity.
allennlp/training/metrics/perplexity.py