Implement transformer_block(x, W1, b1, W2, b2, gamma1, beta1, gamma2, beta2, mode, eps=1e-5): two sublayers with residual connections, with layer normalization placed according to mode.
x has shape (seq_len, d_model). Each sublayer is a linear map (stand-ins for attention and the MLP).eps inside the square root), then scales by gamma_i and shifts by beta_i.mode == "pre_norm": , then .mode == "post_norm": , then .mode raises ValueError.