Concatenation for all combinations for 4D Tensor

I have a 4D Tensor (batch, X, Y, Z). I would like to have all possible concatenations in the last axis ([z_1,1; z_1,2], [z_1,1;z_1,3], …) without permutations (I only want [z_1,1; z_1,2], I dont need [z_1,2; z_1,1]). The output shape of this should be (batch, (XY * (XY-1))/2 ,2Z) Is there a way to get this with vectorized operations without using FOR loops? I looked at link but I cant see how to apply this to my solution.