I think these 2 lines 37 are wrong .
detach() does
Returns a new Tensor, detached from the current graph.

The result will never require gradient.

https://pytorch.org/docs/stable/autograd.html?highlight=detach#torch.Tensor.detach 17