def census(model):
L, d = len(model.blks), model.num_hiddens
emb = d2l.num_params(model.token_emb) + (
d2l.num_params(model.pos_emb) if model.pos == 'learned' else 0)
total = d2l.num_params(model)
print(f'embedding {emb / 1e6:6.2f}M ({emb / total:5.1%}), '
f'blocks {(total - emb) / 1e6:6.2f}M '
f'= {(total - emb) / (L * d ** 2):.2f} L d^2, '
f'total {total / 1e6:.2f}M')
census(gpt(256))
census(gpt(50257, num_hiddens=768, num_heads=12, num_blks=12,
pos='learned', norm='layer', act='gelu', bias=True))