import torch


def save_checkpoint(save_path, model, optimizer, val_loss):
    if save_path == None:
        return
    save_path = save_path
    state_dict = {'model_state_dict': model.state_dict(),
        'optimizer_state_dict': optimizer.state_dict(), 'val_loss': val_loss}
    torch.save(state_dict, save_path)
    print(f'Model saved to ==> {save_path}')


def load_checkpoint(model, optimizer):
    save_path = f'model_check.pt'
    state_dict = torch.load(save_path)
    model.load_state_dict(state_dict['model_state_dict'])
    optimizer.load_state_dict(state_dict['optimizer_state_dict'])
    val_loss = state_dict['val_loss']
    print(f'Model loaded from <== {save_path}')
    return val_loss

66bee630f23468611535fb8bd0573839184dd1ec
<mask token>

<mask token>


def load_checkpoint(model, optimizer):
    save_path = f'model_check.pt'
    state_dict = torch.load(save_path)
    model.load_state_dict(state_dict['model_state_dict'])
    optimizer.load_state_dict(state_dict['optimizer_state_dict'])
    val_loss = state_dict['val_loss']
    print(f'Model loaded from <== {save_path}')
    return val_loss

<mask token>


def save_checkpoint(save_path, model, optimizer, val_loss):
    if save_path == None:
        return
    save_path = save_path
    state_dict = {'model_state_dict': model.state_dict(),
        'optimizer_state_dict': optimizer.state_dict(), 'val_loss': val_loss}
    torch.save(state_dict, save_path)
    print(f'Model saved to ==> {save_path}')


def load_checkpoint(model, optimizer):
    save_path = f'model_check.pt'
    state_dict = torch.load(save_path)
    model.load_state_dict(state_dict['model_state_dict'])
    optimizer.load_state_dict(state_dict['optimizer_state_dict'])
    val_loss = state_dict['val_loss']
    print(f'Model loaded from <== {save_path}')
    return val_loss

import torch


def save_checkpoint(save_path, model, optimizer, val_loss):
    if save_path == None:
        return
    save_path = save_path
    state_dict = {'model_state_dict': model.state_dict(),
        'optimizer_state_dict': optimizer.state_dict(), 'val_loss': val_loss}
    torch.save(state_dict, save_path)
    print(f'Model saved to ==> {save_path}')


def load_checkpoint(model, optimizer):
    save_path = f'model_check.pt'
    state_dict = torch.load(save_path)
    model.load_state_dict(state_dict['model_state_dict'])
    optimizer.load_state_dict(state_dict['optimizer_state_dict'])
    val_loss = state_dict['val_loss']
    print(f'Model loaded from <== {save_path}')
    return val_loss
