<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _sanity_check_no_nested_folds(ir_blocks):
 """Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold."""

    fold_seen = False
    for block in ir_blocks:
        if isinstance(block, Fold):
            if fold_seen:
                raise AssertionError(u'Found a nested Fold contexts: {}'.format(ir_blocks))
            else:
                fold_seen = True
        elif isinstance(block, Unfold):
            if not fold_seen:
                raise AssertionError(u'Found an Unfold block without a matching Fold: '
                                     u'{}'.format(ir_blocks))
            else:
                fold_seen = False