Hi,
Thanks for the code sample but you still didn’t say what you’re trying to accomplish here.

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

This means that the output of your function does not require gradients. You need to make sure that at least one of the input Tensors requires gradients.

feat = output.clone().requires_grad_(True)

This would just make the output require gradients, that won’t make the autograd work with operations that happened before.
You should have your input requiring gradients so that you can compute gradients for it.