    def test_default(self):
        """
        Tests that the default behavior keeps just the last 2 checkpoints.
        """
        default_num_to_keep = 2
        num_epochs = 5
        target = [(e, 0) for e in range(num_epochs - default_num_to_keep, num_epochs)]

        checkpointer = Checkpointer(serialization_dir=self.TEST_DIR)
        for epochs_completed in range(num_epochs):
            for batches_completed in [0, 5, 10]:
                state = {
                    "epochs_completed": epochs_completed,
                    "batches_in_epoch_completed": batches_completed,
                }
                checkpointer.maybe_save_checkpoint(
                    FakeTrainer(model_state=state, training_state=state),
                    epochs_completed,
                    batches_completed,
                )
        models, training = self.retrieve_and_delete_saved()
        assert models == training == target
Tests that the default behavior keeps just the last 2 checkpoints.
tests/training/checkpointer_test.py