Solved by tom in post #2 
              
              
                I think you want to give more context than that. I assume that phi is your “ground truth loss” (x being the ground truth or some such information) and psi the consistency loss. 
Now psi is rather underspecified in the formula. From your description, I looks like that i,j iterates over all pairs of a…