Implement PyTorch training loop | Amazon Coding Question