import re
from typing import Counter


def count_words(text):
    """Count how many times each unique word occurs in text."""
    # counts = dict()  # dictionary of { <word>: <count> } pairs to return

    # Convert to lowercase
    text = text.lower()

    # Split text into tokens (words), leaving out punctuation
    # (Hint: Use regex to split on non-alphanumeric characters)
    text = re.sub(r"[^a-zA-Z0-9]", " ", text)
    words = text.split()

    # Aggregate word counts using a dictionary
    counts = Counter(words)

    return counts