RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

Answered here.
Please don’t cross-post the same issues, as multiple users might work on the solution although it might already be solved. Let’s stick to the created topic.