InternLM2 / InternLM2.5 modeling port

Copyright (c) The InternLM team and The HuggingFace Inc. team. All rights reserved.
Adaptations for Transformers 5: Copyright 2026 ModelCloud.ai.

Derived from configuration_internlm2.py and modeling_internlm2.py in
https://huggingface.co/internlm/internlm2_5-1_8b-chat
revision 57dcbc5455bf050d27a80f0ebd7808387caa714d.
These files are Apache-2.0 licensed, derived in turn from Hugging Face Llama.
See the repository root LICENSE for the Apache-2.0 license terms.

tokenization_internlm2.py uses the common InternLM SentencePiece algorithm
through a package-local import. The inspected Apache-2.0 source is
https://huggingface.co/internlm/internlm2_5-7b-chat
revision eb72b541689b0432dade0435feb339b89fdd39ff, tokenization_internlm2.py.

Only source code is distributed here, not upstream weights or vocabulary assets.
The upstream model-weight license is separate and is not superseded by this port.
