    def _maybe_restore_checkpoint(self) -> None:
        """
        Restores the model and training state from the last saved checkpoint.
        This includes an epoch count and optimizer state, which is serialized separately
        from model parameters. This function should only be used to continue training -
        if you wish to load a model for inference/load parts of a model into a new
        computation graph, you should use the native Pytorch functions:
        `model.load_state_dict(torch.load("/path/to/model/weights.th"))`

        If `self._serialization_dir` does not exist or does not contain any checkpointed weights,
        this function will do nothing.
        """
        if self._checkpointer is None:
            return

        state = self._checkpointer.load_checkpoint()
        if state is None:
            self._start_after_epochs_completed = 0
            self._start_after_batches_in_epoch_completed = 0
            self._best_model_filename = None
            return

        model_state, training_state = state
        if training_state["version"] != 1:
            raise ValueError(
                f"This version of {self.__class__.__name__} only supports checkpoints of version 1. "
                f"Found version {training_state['version']}"
            )

        if self._distributed:
            assert self._ddp_wrapped_model is not None
            self._ddp_wrapped_model.load_state_dict(model_state)
        else:
            self._pytorch_model.load_state_dict(model_state)

        self._metric_tracker.load_state_dict(training_state["metric_tracker"])
        self.optimizer.load_state_dict(training_state["optimizer"])

        for cb, state_dict in zip(self._callbacks, training_state["callbacks"]):
            cb.load_state_dict(state_dict)

        if self._learning_rate_scheduler is not None:
            self._learning_rate_scheduler.load_state_dict(training_state["learning_rate_scheduler"])
        if self._momentum_scheduler is not None:
            self._momentum_scheduler.load_state_dict(training_state["momentum_scheduler"])
        if self._moving_average is not None:
            self._moving_average.load_state_dict(training_state["moving_average"])

        self._start_after_epochs_completed = training_state["epochs_completed"]
        self._start_after_batches_in_epoch_completed = training_state["batches_in_epoch_completed"]
        self._best_model_filename = training_state["best_model_filename"]
Restores the model and training state from the last saved checkpoint.
This includes an epoch count and optimizer state, which is serialized separately
from model parameters. This function should only be used to continue training -
if you wish to load a model for inference/load parts of a model into a new
computation graph, you should use the native Pytorch functions:
`model.load_state_dict(torch.load("/path/to/model/weights.th"))`

If `self._serialization_dir` does not exist or does not contain any checkpointed weights,
this function will do nothing.
allennlp/training/gradient_descent_trainer.py