code: def _sanity_check_no_nested_folds(ir_blocks):
      
      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
docs: Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.