def METHOD_NAME(line):
    m = intel_hex_re.match(line)
    if not m:
        raise CLEError("Invalid HEX record: " + line)
    my_cksum = 0
    count, addr, rectype, data, cksum = m.groups()
    cksum = int(cksum, 16)
    for d in binascii.unhexlify(line[1:-2]):
        my_cksum = (my_cksum + d) % 256
    my_cksum = ((my_cksum ^ 0xFF) + 1) % 256
    if my_cksum != cksum:
        raise CLEError(f"Invalid checksum: Computed {hex(my_cksum)}, found {hex(cksum)}")
    count = int(count, 16)
    addr = int(addr, 16)
    rectype = int(rectype, 16)
    if data:
        data = binascii.unhexlify(data)
    if data and count != len(data):
        raise CLEError("Data length field does not match length of actual data: " + line)
    return rectype, addr, data