Implement PyTorch training loop | Amazon Interview Question