def _save_model(self):
        """Saves the model.

        Args:
            epoch: the epoch this iteration is in.
            batch: the batch this iteration is in. `None` if the `save_freq`
                is set to `"epoch"`.
            logs: the `logs` dict passed in to `on_batch_end` or `on_epoch_end`.
        """
        # Create host directory if it doesn't exist.
        if not file_utils.exists(self.backup_dir):
            file_utils.makedirs(self.backup_dir)
        if self.double_checkpoint and file_utils.exists(self._weights_path):
            file_utils.copy(self._weights_path, self._prev_weights_path)
        if self.double_checkpoint and file_utils.exists(
            self._training_metadata_path
        ):
            file_utils.copy(
                self._training_metadata_path, self._prev_training_metadata_path
            )
        self.model.save_weights(filepath=self._weights_path, overwrite=True)
        with file_utils.File(self._training_metadata_path, "w") as f:
            training_metadata = {
                "epoch": self._current_epoch,
                "batch": self._last_batch_seen,
            }
            f.write(json.dumps(training_metadata))
Saves the model.

        Args:
            epoch: the epoch this iteration is in.
            batch: the batch this iteration is in. `None` if the `save_freq`
                is set to `"epoch"`.
            logs: the `logs` dict passed in to `on_batch_end` or `on_epoch_end`.
        
keras/src/callbacks/backup_and_restore.py