Solved by albanD in post #4 
              
              
                The problem is that here you return model, criterion, optimizer 
But here you unpack model, optimizer, criterion. 
Notice that the optimizer and criterion are swapped. You need to swap them back.