Do not erase a cache_position passed explicitly to generate(), if there is one
Author: FremyCompany
Pull request: yes

# What does this PR do?

Currently, any `cache_position` passed to `model.generate()` is silently replaced by the initial initialization. This seems wrong, since there is no need to reinitialize an argument that has already been passed. In some models, being able to pass custom cache_positions which are not 0-initialized is required for proper behavior.

This PR adds a check to the initialization code of model_kwargs['cache_position'] to return early if that argument was already provided.

There is no linked issue because I fixed the bug before filing an issue. PR is thus easier.

## 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).
- [ ] Did you write any new necessary tests?

I don't think that this warrants any documentation change, the current behavior is not described anywhere. I could add a test, but it would be very artificial. I think merging as-is is fine, but I welcome feedback.

## 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.

@ArthurZucker @zucchini-nlp @gante

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.

The use case is related to Mamba models, so the logic for initializing the cache position unfortunately doesn't work because there is no way to know how many tokens were already processed, and starting with index 0 disables the cache since it is supposed not to be initialized yet for the first token.

Calling generate is the easiest way to continue generating after the first batch of tokens. Calling forward directly would also work but then it's necessary to reimplement all the sampling stuff which generate usually does for you in a very convenient way.

Yes, will do tomorrow.

@FremyCompany to make our CI happy:
- Tag the PR as `Ready for review` (button at the bottom of the PR page)
- run `make fixup` on your terminal, inside the `transformers` root folder (this runs automated code formatting)
- commit the changes

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37986). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.