How to implement GPT-2 from scratch like Karpathy

I spent two hours watching Andrej Karpathy build GPT from scratch, nodding along like it was clicking. Then I opened a blank file to build…