Hello,
In my project, I need to compute the gradient wrt the input for each output, basically by doing something like this:
for index in selected_outputs:
    output[:,index].backward(retrain_variables=True)
    # the code continues from here

The batch size at the input is only one here. I observed that each backward() takes about the same time in each iteration and causing the loop to take a lot of time. Is there a better way to do this?