Hi,

Why do you use retain_graph=True this should not be needed here.
Do not use .data for your paremeter update, wrap it in with torch.no_grad(): context manager and just do y -= y.grad * learning_rate.