code: def rfind(self, bs, start=None, end=None, bytealigned=None):
          
          bs = Bits(bs)
          start, end = self._validate_slice(start, end)
          if bytealigned is None:
              bytealigned = globals()['bytealigned']
          if not bs.len:
              raise ValueError("Cannot find an empty bitstring.")
          # Search chunks starting near the end and then moving back
          # until we find bs.
          increment = max(8192, bs.len * 80)
          buffersize = min(increment + bs.len, end - start)
          pos = max(start, end - buffersize)
          while True:
              found = list(self.findall(bs, start=pos, end=pos + buffersize,
                                        bytealigned=bytealigned))
              if not found:
                  if pos == start:
                      return ()
                  pos = max(start, pos - increment)
                  continue
              return (found[-1],)
docs: Find final occurrence of substring bs.
  
          Returns a single item tuple with the bit position if found, or an
          empty tuple if not found. The bit position (pos property) will
          also be set to the start of the substring if it is found.
  
          bs -- The bitstring to find.
          start -- The bit position to end the reverse search. Defaults to 0.
          end -- The bit position one past the first bit to reverse search.
                 Defaults to self.len.
          bytealigned -- If True the bitstring will only be found on byte
                         boundaries.
  
          Raises ValueError if bs is empty, if start < 0, if end > self.len or
          if end < start.