When you add new special tokens (e.g. <|user|>, <|assistant|>, domain markers) to a tokenizer after a language model has already been built, the model's token embedding matrix and its output projection (LM head) must be resized so that the new token IDs have valid rows.
Implement resize_lm_head(tok_emb, out_head, new_vocab_size, init_value) that performs this weight-preserving resize.
tok_emb: 2D array-like of shape (V, d) -- the current token embedding matrix.out_head: 2D array-like of shape (V, d) -- the current output head weight matrix (as in nn.Linear(d, V, bias=False), whose .weight has shape (V, d)).new_vocab_size: int, the desired vocabulary size V_new.init_value: float, the scalar value used to fill every new row that is appended.V_new == V, return copies of the inputs unchanged.V_new > V, append V_new - V new rows of length d to BOTH matrices. Every entry in every appended row must equal init_value. The original V rows must be preserved exactly and remain at indices 0 .. V-1.V_new < V, raise a ValueError.Return a single list [new_tok_emb, new_out_head] where each element is a 2D Python list (use .tolist() on numpy arrays).