Thanks for the explanation!
Your experiment sounds really interesting.
Rewrapping output in a tensor also detaches the graph.
Your code should work with the following changes:
...
     outputs.append(image_energy)
outputs = torch.stack(outputs)
loss, rmse = self.get_loss(outputs, targets, 4)

Could you check for valid results?