You are breaking the computation graph, when you use list() and/or torch.Tensor().



 alnshbn:

squared_diff = torch.reshape(torch.Tensor(squared_diff), (len(instance_predictions), len(instance_predictions))