ATTENTION & TRANSFORMERS / LATENT SPACE

Use Python 3.12+ and install numpy and torch:
  python -m pip install numpy torch

Keep all six .py files in the same directory, then run:
  python foundations_numpy.py
  python foundations_torch.py
  python numpy_core.py
  python torch_core.py
  python verify.py
  python train_copy.py --steps 800 --seed 7

The NumPy file implements transparent forward passes; it does not implement
automatic differentiation. The PyTorch file adds trainable modules and the
training script optimizes a small encoder-decoder model on a synthetic task.
The code shown in the course is extracted from these files at build time.

All functions declare parameter and return types. NumPy aliases specify dtype;
docstrings and checks specify shapes. Type hints alone do not validate dimensions.
The site's source reader highlights the lesson's exact lines and can visualize
recorded example executions. The browser does not execute arbitrary Python.

Conventions: B=batch, S=source length, T=target length, D=model width.
Masks use True=visible, unlike nn.MultiheadAttention's boolean mask convention.
This teaching model uses pre-norm, sinusoidal positions, ReLU, one encoder block,
one decoder block, and no dropout. It is not a checkpoint-compatible recreation
of the original 2017 architecture or an optimized serving implementation.

The experiment evaluates held-out sequences of the same bounded lengths and
vocabulary as training. Its score is not evidence of natural-language ability
or generalization to longer sequences. Runtimes/results can vary by environment.
