    except OverflowError:
        perplexity = float("inf")
    print(f"epoch {epoch}: perplexity: {perplexity} eval_loss: {eval_loss}")
    base_log = {
        "perplexity": perplexity,

        "train_loss": train_loss.item(),
        "epoch": epoch,
        "step": completed_steps,
    }
    accelerator.log(base_log, step=completed_steps)
