support telechat2
Author: shunxing12345
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

## Description

This PR introduces **TeleChat2**, a new model designed for [specific use case, e.g., multilingual conversational AI or general-purpose language modeling]. TeleChat2 supports model sizes of [e.g., 3B, 7B, and 35B] and has been pre-trained and fine-tuned on large datasets across English and Chinese. 

## Motivation

Adding TeleChat2 to the Transformers repository allows the community to benefit from its capabilities, leveraging state-of-the-art performance on [specific benchmarks or tasks]. This inclusion aligns with the repository's goal of supporting a diverse range of models and architectures.

## Key Changes

1. Added `TeleChat2Config` for model configuration.
2. Added `TeleChat2Model`, `TeleChat2ForCausalLM`, and corresponding tokenizers.
3. Included detailed documentation and tests to ensure compatibility and coverage.
4. Updated integration points in `AutoModel` and other relevant files.

## Documentation and Tests

- Model architecture, configuration, and usage examples are documented in [relevant files].
- Added unit tests for pretraining and fine-tuning workflows.



## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker
- vision models: @amyeroberts, @qubvel
- speech models: @ylacombe, @eustlb
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc @MekkCyber

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Hi team, 👋

Just following up on this PR. I understand you may have a lot on your plate, but I’d love to hear your thoughts or feedback on this contribution whenever you have time. Please let me know if there’s anything I can do to assist or improve the PR!

Thanks for your time and all the great work you do maintaining this repository! 🙏

Best,

Hey @shunxing12345 👋 

Most of us are on holidays this week for the new year. The rhythm will pickup early next week and the team will review your PR as soon as possible. Thanks a lot for your patience and your contribution 🤗 

cc @ArthurZucker feel free to ping someone for a first review!

> Hey @shunxing12345 👋
> 
> Most of us are on holidays this week for the new year. The rhythm will pickup early next week and the team will review your PR as soon as possible. Thanks a lot for your patience and your contribution 🤗

Thank you for the update and for letting me know! I completely understand that it's a holiday period. I'll patiently wait for the team to review the PR, and I appreciate all your efforts. Wishing you a Happy New Year! 🎉

Hi @LysandreJik @ArthurZucker ,
Hope you had a wonderful holiday! I just wanted to politely follow up on the work we discussed. Please let me know if there’s anything I can update or clarify to help move things forward. I appreciate your time and look forward to any feedback. Thank you, and happy new year!

Hey! 🤗 Happy new year ! @Cyrilvallez will review this! 🤗 

@Cyrilvallez  Thank you for your support! I noticed that some classes or methods differ only in terms of their parameters, while the overall logic remains consistent.

To avoid duplicating code, could you suggest a best practice for handling such cases? For example:

1. Would it be appropriate to introduce a base class or utility method to centralize the shared logic and allow parameter customization through inheritance or function arguments?
2. Alternatively, is there a recommended pattern in the modular design to efficiently handle such cases?

I truly appreciate your insights and guidance on this matter. Thank you for your time and support!

> Thanks for the docs!

@stevhliu  Thank you for your review! I have updated the docs as requested. Please let me know if there's anything else that needs adjustment. 😊

> Hey! Thanks for the contribution and your patience! From what I can see, this is already in a very healthy state! 🤗 You are on page with our latest Attention standards 👌 However, you miss a modular file! We no longer use the "Copied from" syntax, in favor of a "modular file". You can get started with [this link](https://huggingface.co/docs/transformers/main/en/modular_transformers), and check other models' modular file (look for `modular_xxx.py` in the library, e.g. `modular_mistral`) for examples! We basically use inheritance in the modular, which is then automatically unravelled in the "modeling file" based on the inherited model. So for example, classes which are fully "Copied from" can very simply inherit from the base class 😉 Let me know if you need more guidance/have any questions!

Hi @Cyrilvallez ,

Thank you so much for your feedback and detailed guidance! 😊 I’ve addressed the issue and added the modular file as suggested. Please let me know if there’s anything else I should refine or improve further.

Thanks again for your support!

Hi @Cyrilvallez 

Thanks for your guidance and suggestions! I’ve addressed the issues and completed the necessary updates as per your feedback. Please let me know if there’s anything else I should refine. 😊

Best regards!

hi @Cyrilvallez 
Just a gentle follow-up regarding the PR. When you have a moment, could you kindly review it? Please let me know if there's anything further you'd like me to adjust or refine.

Thank you so much for your time!

Best regards

Hi @Cyrilvallez ,

Thanks for the review! I have addressed all the comments, and the changes have been updated. Please let me know if there is anything else to improve.

Cheers! 😊


hi @Cyrilvallez ,
Thank you so much for your thoughtful guidance! I have completed all the requested changes and carefully reviewed the updates.

Hi @Cyrilvallez,

I hope this message finds you well. I just wanted to kindly follow up regarding the updates I’ve made based on your valuable feedback. Please let me know if there’s anything else I can refine or improve.

Thank you so much for your time and guidance!

Best regards,

HI, @Cyrilvallez 
The config has been updated as requested! However, it seems that some errors in the autotest are related to HTTP issues. Let me know if you have any insights on this. 😊

@Cyrilvallez , Hello!
All the automated tests for this PR have passed, and we’ve addressed the previously mentioned HTTP issues. Could you please take a moment to review it again? If there’s any feedback or suggestions, let me know. Thank you so much!

Hi @Cyrilvallez ,

I hope you're doing well! Just wanted to follow up on this PR—since all automated tests have passed and the previous HTTP issues have been addressed, could you kindly take a moment to review it again? Let me know if there's anything else that needs improvement.

Looking forward to your feedback. Thanks a lot! 😊

@Cyrilvallez had a conference this week let me have a final look!

Hi @ArthurZucker ,

Thanks for the update! I appreciate you taking the time to review it. Let me know if you need any clarifications or further modifications. Looking forward to your feedback!

@shunxing12345 are you still planning to merge? 

这是来自QQ邮箱的假期自动回复邮件。
 
您好，我最近正在休假中，无法亲自回复您的邮件。我将在假期结束后，尽快给您回复。