def groups_score(str_group):
    """
    >>> groups_score('<>')
    {'score': 0, 'groups': 0, 'garbage': 0}

    >>> groups_score('<<<<>')
    {'score': 0, 'groups': 0, 'garbage: 3}

    >>> groups_score('<{!>}>')
    {'score': 0, 'groups': 0, 'garbage': 2}

    >>> groups_score('<!!>')
    {'score': 0, 'groups': 0, 'garbage': 0}

    >>> groups_score('<!!!>>')
    {'score': 0, 'groups': 0, 'garbage': 0}

    >>> groups_score('<{o"i!a,<{i<a>')
    {'score': 0, 'groups': 0, 'garbage': 10}

    >>> groups_score('{}')
    {'score': 1, 'groups': 1, 'garbage': 0}

    >>> groups_score('{{{}}}')
    {'score': 6, 'groups': 3, 'garbage': 0}

    >>> groups_score('{{},{}}')
    {'score': 5, 'groups': 3, 'garbage': 0}

    >>> groups_score('{{{},{},{{}}}}')
    {'score': 16, 'groups': 6, 'garbage': 0}

    >>> groups_score('{<a>,<a>,<a>,<a>}')
    {'score': 1, 'groups': 1, 'garbage': 4}

    >>> groups_score('{{<a>},{<a>},{<a>},{<a>}}')
    {'score': 9, 'groups': 5, 'garbage': 4}

    >>> groups_score('{{<a!>},{<a!>},{<a!>},{<ab>}}')
    {'score': 3, 'groups': 2, 'garbage': 17}

    """
    in_garbage = False
    current_level = 0
    groups = 0
    score = 0
    garbage = 0
    n = 0

    while n < len(str_group):
        if str_group[n] == '!':
            n += 2
            continue

        if str_group[n] == '>':
            in_garbage = False
            n += 1
            continue

        if in_garbage:
            n += 1
            garbage += 1
            continue

        if str_group[n] == '<':
            in_garbage = True
            n += 1
            continue

        if str_group[n] == '{':
            groups += 1
            current_level += 1
            score += current_level
            n += 1
            continue

        if str_group[n] == '}':
            current_level -= 1
            n += 1
            continue

        n += 1

    return {'score': score, 'garbage': garbage, 'groups': groups}