<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ungap_index_map(sequence, gap_chars='-'):
 """ Returns a dict mapping from an index in the ungapped sequence to an index in the gapped sequence. {0: 0, 1: 1, 2: 3, 3: 4} """

    counter = itertools.count(0).__next__
    ungap_indexes = [
        counter() if c not in gap_chars else None for c in iter(sequence)
    ]
    return dict(
        (ungapped, gapped)
        for ungapped, gapped in zip(ungap_indexes, range(len(sequence)))
        if ungapped is not None)