keras/src/callbacks/backup_and_restore.py/BackupAndRestore/__init__
class BackupAndRestore:    def __init__(
        self,
        backup_dir,
        save_freq="epoch",
        delete_checkpoint=True,
    ):
        super().__init__()
        self.save_freq = save_freq
        self.delete_checkpoint = delete_checkpoint
        self._batches_seen_since_last_saving = 0
        self._last_batch_seen = 0
        self._current_epoch = 0

        if not backup_dir:
            raise ValueError("Empty `backup_dir` argument passed")
        self.backup_dir = backup_dir
        self._weights_path = file_utils.join(backup_dir, "latest.weights.h5")
        self._training_metadata_path = file_utils.join(
            backup_dir, "training_metadata.json"
        )
        if save_freq != "epoch" and not isinstance(save_freq, int):
            raise ValueError(
                "Invalid value for argument `save_freq`. "
                f"Received: save_freq={save_freq}. "
                "Expected either 'epoch' or an integer value."
            )