import torch
from torchmetrics.text import Perplexity
metric = Perplexity()
values = [ ]
for _ in range(10):
    values.append(metric(torch.rand(2, 8, 5), torch.randint(5, (2, 8))))
fig_, ax_ = metric.plot(values)
