ValueError: can't optimize a non-leaf Tensor?

@albanD Thanks so much.
One more question: I dnt understand why it’s nessary to use with torch.no_grad()?
Could u kindly explain some case going wrong if no use torch.no_grad()?