During the training (in the trainer.Trainer.train() method), if the loss is nan (such as when using very few datapoints, like in #528), checkpoint_model is never created, thus the crashes and gives the following error:
UnboundLocalError: local variable 'checkpoint_model' referenced before assignment
TODO: