import torch


def load_model(model, model_path, optimizer_path=None):
    """
    Loads model and optimizer (if given) from state_dict
    """
    model.load_state_dict( torch.load(model_path))
    if optimizer_path:
        optim = torch.load(optimizer_path)
        return model, optim
    return model