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.

The constraints are defined by a binning of the Majoranas into bins such that Majoranas in bin n commute with symmetry S_i if the ith binary digit of n is 0.

binned_majoranas(list of lists of integers): majoranas to be paired, separated up by their symmetry bins.

pairing(tuple): one of the desired pairings