def test_log_on_train_start(mock_log_metrics, tmp_path):
    """Tests that logged metrics on_train_start get reset after the first epoch."""

    class MyModel(BoringModel):
        def on_train_start(self):
            self.log("foo", 123)

    model = MyModel()
    trainer = Trainer(
        default_root_dir=tmp_path,
        limit_train_batches=1,
        limit_val_batches=0,
        max_epochs=2,
        log_every_n_steps=1,
        enable_model_summary=False,
        enable_checkpointing=False,
        enable_progress_bar=False,
        logger=TensorBoardLogger(tmp_path),
    )
    trainer.fit(model)

    assert mock_log_metrics.mock_calls == [call(metrics={"foo": 123.0, "epoch": 0}, step=0)]
    assert trainer.max_epochs > 1
Tests that logged metrics on_train_start get reset after the first epoch.
tests/tests_pytorch/trainer/logging_/test_train_loop_logging.py