Using .clone() does not invalidate backprop. The tensor you obtain is a brand new tensor whose storage is disconnected from the original tensor but still remembers (through the graph) how it was computed.
I skimmed through your code, I think you want to use a list of list of list for y_pred and only at the end, turn it into a tensor before returning.