def byte_offset(self, bytes):
remaining_bytes = bytes<EOL>for r in self:<EOL><INDENT>if r.is_open() or r.byte_length() >= remaining_bytes:<EOL><INDENT>return r.start + remaining_bytes<EOL><DEDENT>else:<EOL><INDENT>remaining_bytes -= r.byte_length()<EOL><DEDENT><DEDENT>assert False, "<STR_LIT>".format(bytes, self)<EOL>
Maps `bytes` length to a sequence's offset. For example, if we do byte_offset(5) and our list of sequences is
[(0, 2), (10, 11), (40, 45)] then the returned value will be 42.
Note that `bytes` must be <= byte_length().
:returns: actual offset in one of the sequences in the range for request byte length.
:rtype: int or float