def search_revert(self, bas, ba, beam_size):
pba = ba.copy()<EOL>self.permute(pba)<EOL>assert(beam_size % <NUM_LIT:2> == <NUM_LIT:0>)<EOL>half_beam = beam_size / <NUM_LIT:2><EOL>idx = bisect_left(bas, (pba, ba))<EOL>start = int(max(<NUM_LIT:0>, idx - half_beam))<EOL>end = int(min(len(bas), idx + half_beam))<EOL>res = bas[start:end]<EOL>res = [x[<NUM_LIT:1>] for x in res]<EOL>return res<EOL>
ba: query bitarray
bas: a sorted list of tuples of (permuted bitarray, original bitarray)
return : query bitarray's beam-size neighbours (unpermuted bitarray)