#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1188
Task: ,</think>

Write a Python function that transforms a given paragraph of text into a sequence of nested dictionaries, where each word is a key mapped to its count within each sentence, and sentences ar
Generated: 2026-02-12T23:28:41.094134
"""

import re

def paragraph_to_nested_dict(paragraph):
    sentences = re.split(r'(?<=[.!?])\s+', paragraph)
    result = {}
    for idx, sentence in enumerate(sentences):
        words = sentence.split()
        word_counts = {}
        for word in words:
            word_counts[word] = word_counts.get(word, 0) + 1
        result[f'sentence_{idx + 1}'] = word_counts
    return result

if __name__ == '__main__':
    example_paragraph = "Hello world! Hello again. This is a test. Hello world!"
    result = paragraph_to_nested_dict(example_paragraph)
    print(result)