Isn’t it just the loss plotting?
First you start with 0, then your add the new loss (divide by 20), then you add again the new loss to the old loss and divide again by 20, until 20 times done…you’re just accumulation your loss, while chaining the divide by 20 (its bad explained but idk how to do it better). Maybe store your loss in a list until 20 batches reach and plot the mean of those or you write
running_loss += loss.item() / 20

and save them only after 20 batches to your loss_values
loss_values.append(running_loss)
running_loss  = 0