[fix] make legacy bnb code work
Author: cyr0930
Pull request: yes

# What does this PR do?
bnb 8bit optimizer related logic doesn't work anymore because optimizer class name has been changed.
This logic set optim_bits to 32 instead of 8 to stabilize training with 8-bit optimizer.
And legacy code apply this only to 8bit-Adam, so I changed it to be applied to all 8-bit optimizers.

## Before submitting
- [ ] 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?
- [ ] 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.
- [ ] 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?
@SunMarc

<!-- 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: @eustlb
- graph models: @clefourrier

Library:

- flax: @gante and @Rocketknight1
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @zach-huggingface and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @SunMarc @zach-huggingface
- 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: @Rocketknight1
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

I think this commit (https://github.com/huggingface/transformers/commit/796162c51298547c357b20cc33d64cbcf77d0241#diff-ed55888e6665791fe92cc8fc0c499da54f4ace6738551cd9a2591881cda076deR1207) is the cause of this issue.
Trainer imports "Adam8bit" before but after this commit it imports "AdamW" (https://github.com/bitsandbytes-foundation/bitsandbytes/blob/main/bitsandbytes/optim/adamw.py).

The commit you are showing is like 2 years old. Do you have a script that shows the issue you are experiencing ? 

Okay but it may take some time because I have to deal with something else now. Thanks for the review :)

sorry for the late response.
here is the minimal? reproducible code.
hope it helps :)

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, Trainer, TrainingArguments, TrainerCallback
from datasets import load_dataset

model_path = "Qwen/Qwen2.5-0.5B"
tokenizer = AutoTokenizer.from_pretrained(model_path)

dataset = load_dataset("wikitext", "wikitext-2-raw-v1")
tokenized_data = dataset.map(lambda x: tokenizer(x["text"]))


class CustomCallback(TrainerCallback):
    def on_train_begin(self, args, state, control, **kwargs):
        optimizer = kwargs["optimizer"]
        optimizer_cls = optimizer.__class__
        assert optimizer_cls.__name__ == "AdamW"    # not Adam8bit
        assert "bitsandbytes" in str(optimizer_cls)
        assert optimizer.args.optim_bits == 8
        modules = optimizer.mng.module_weight_config_triple
        assert modules  # this should not be empty but it is empty now
        module, name, config = modules[0]
        assert isinstance(module, torch.nn.Embedding)
        assert name == "weight"
        assert config["optim_bits"] == 32
        return super().on_train_begin(args, state, control, **kwargs)


model = AutoModelForCausalLM.from_pretrained(model_path)
training_args = TrainingArguments(
    per_device_train_batch_size=1,
    save_strategy="no",
    max_steps=1,
    optim="adamw_8bit",
)
trainer = Trainer(
    model,
    training_args,
    train_dataset=tokenized_data,
    callbacks=[CustomCallback],
)

trainer.train()
```

> Thanks for the reproducer @cyr0930, I was able to better understand the issue. Would you mind adding a small test to check this ? You can pretty much use the same example as you shared but maybe switch to a custom model like the other trainer + optimizer tests ?

I added a test case. Feel free to tell me if there's something I can improve. Thanks :)

Oh I fixed author because I mis-commit them with my company account.
But commits look ugly now. Is it okay? I'm asking this because I never experienced this situation before.
Sorry for bothering you

Ah I think I fixed it!

Failing tests are unrelated, i'll try to merge this when they pass