Generates symmetry-respecting pairings between four-elements in a list

A pairing of a list is a set of pairs of list elements. E.g. a pairing of

labels = [1, 2, 3, 4, 5, 6, 7, 8]

could be

[(1, 2), (3, 4), (5, 6), (7, 8)]

(Note that we insist each element only appears in a pairing once; the following is not a pairing:

[(1, 1), (2, 2), (3, 4), (5, 6), (7, 8)]

This function generates a pairing of a list of Majoranas that covers all 2-RDM elements that conserve a set of symmetry conditions. That is, this function guarantees that for any four elements (i,j,k,l) in the input, if the corresponding RDM term gamma_igamma_jgamma_kgamma_l satisfies a symmetry of the system, the pairs (i,j) and (k,l) will appear simultaneously in at least one pairing.

We assume in this function that each symmetry divides the set of Majoranas in two, indexed by their binary digits.

num_fermions int

The number of fermions to be considered (the number of Majoranas generated will be twice this size)

num_symmetries int

the number of symmetries to be respectd.