<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_variant(variant):
 """Read and parse a binary protobuf variant value."""

    result = 0
    cnt = 0
    for data in variant:
        result |= (data & 0x7f) << (7 * cnt)
        cnt += 1
        if not data & 0x80:
            return result, variant[cnt:]
    raise Exception('invalid variant')