<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def monitor_resource_sync_state(resource, callback, exit_event=None):
 """Coroutine that monitors a KATCPResource's sync state. Calls callback(True/False) whenever the resource becomes synced or unsynced. Will always do an initial callback(False) call. Exits without calling callback() if exit_event is set """

    exit_event = exit_event or AsyncEvent()
    callback(False)        # Initial condition, assume resource is not connected

    while not exit_event.is_set():
        # Wait for resource to be synced
        yield until_any(resource.until_synced(), exit_event.until_set())
        if exit_event.is_set():
            break       # If exit event is set we stop without calling callback
        else:
            callback(True)

        # Wait for resource to be un-synced
        yield until_any(resource.until_not_synced(), exit_event.until_set())
        if exit_event.is_set():
            break       # If exit event is set we stop without calling callback
        else:
            callback(False)