code: def _translate_range(self, len_, start, end):
          
          if start < 0:
              start += len_
          start = max(0, min(start, len_))
          if end < 0:
              end += len_
          end = max(-1, min(end, len_ - 1))
          return start, end
docs: Translate range to valid bounds.