code: def range_interleave(ranges, sizes={}, empty=False):
      
      from jcvi.utils.iter import pairwise
      ranges = range_merge(ranges)
      interleaved_ranges = []
  
      for ch, cranges in groupby(ranges, key=lambda x: x[0]):
          cranges = list(cranges)
          size = sizes.get(ch, None)
          if size:
              ch, astart, aend = cranges[0]
              if astart > 1:
                  interleaved_ranges.append((ch, 1, astart - 1))
              elif empty:
                  interleaved_ranges.append(None)
  
          for a, b in pairwise(cranges):
              ch, astart, aend = a
              ch, bstart, bend = b
              istart, iend = aend + 1, bstart - 1
              if istart <= iend:
                  interleaved_ranges.append((ch, istart, iend))
              elif empty:
                  interleaved_ranges.append(None)
  
          if size:
              ch, astart, aend = cranges[-1]
              if aend < size:
                  interleaved_ranges.append((ch, aend + 1, size))
              elif empty:
                  interleaved_ranges.append(None)
  
      return interleaved_ranges
docs: Returns the ranges in between the given ranges.
  
      >>> ranges = [("1", 30, 40), ("1", 45, 50), ("1", 10, 30)]
      >>> range_interleave(ranges)
      [('1', 41, 44)]
      >>> ranges = [("1", 30, 40), ("1", 42, 50)]
      >>> range_interleave(ranges)
      [('1', 41, 41)]
      >>> range_interleave(ranges, sizes={"1": 70})
      [('1', 1, 29), ('1', 41, 41), ('1', 51, 70)]