Well, if x contains F elements and y contains F elements then there are FxF pairings, not 2xF pairings.
But, I had forgotten that there are two elements in each pairing. So the size should be NxFxFx2.
I can’t see why you need the pairings but this should do it.
A = A.unsqueeze(2).repeat([1, 1, F]) # shape NxFxF with every value repeated along the last dim
B = B.unsqueeze(1).repeat([1, F, 1]) # shape NxFxF with every value repeated along the middle dim
C = torch.stack((A, B), dim=3)

C has 4 dimensions of size N, F, F, 2
C[n, fb, fa] contains the pairing A[fa], B[fb] from batch n.