class_docstr: Permute provide a random [n] -> [n] permute operation.
  e.g, a [3] -> [3] permute operation could be:
  [0,1,2] -> [1,0,2], "010" => "100"
docstr: ba: query bitarray
  bas: a sorted list of tuples of (permuted bitarray, original bitarray)
  return : query bitarray's beam-size neighbours (unpermuted bitarray)
docstr_tok: ["ba",":","query","bitarray","bas",":","a","sorted","list","of","tuples","of","(","permuted","bitarray",",","original","bitarray",")","return",":","query","bitarray","'s","beam-size","neighbours","(","unpermuted","bitarray",")"]
code: def search_revert(self, bas, ba, beam_size):
      """
      ba: query bitarray
      bas: a sorted list of tuples of (permuted bitarray, original bitarray)
      return : query bitarray's beam-size neighbours (unpermuted bitarray)
      """
      pba = ba.copy()
      self.permute(pba)
      assert beam_size % 2 == 0
      half_beam = beam_size / 2
  
      # binary search (pba,ba) in bas
      idx = bisect_left(bas, (pba, ba))
  
      start = int(max(0, idx - half_beam))
      end = int(min(len(bas), idx + half_beam))
  
      res = bas[start:end]
  
      # return the original(unpermuted) keys
      res = [x[1] for x in res]
      return res
  
imports: import random
  from bisect import bisect_left
label_desc: Use image node_id 4 for calling the Permute obj's underlying member method code with example usage: obj.search_revert(bas, ba, beam_size) and returns: res