Ok I think it’s in the place u typed ‘-positions.grad’
Remove the ‘.grad’ because u already specified “with torch.no_grad( )” and this automatically removes all gradients from all tensors so it’s like calling the gradient that doesn’t even exist