Fix: Guard against None num_query_tokens in Blip2Processor (to avoid TypeError)
Author: Flakes342
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 -->

Fixes #42203 


## 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?
- [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?

### Fixed a bug where Blip2Processor assumes num_query_tokens is an int and does `max_length - self.num_query_tokens` which raises TypeError when `num_query_tokens` is None.

This change:
- Treats num_query_tokens as 0 when it is None (with a warning).
- Adds a minimal unit test to prevent regression.

## Who can review?
@Rocketknight1 


Comments:
cc @zucchini-nlp! I think it's fine without the warning message, but deferring to her on what behaviour we want from processors :sweat_smile: 

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

@zucchini-nlp thr pr is ready for your review

run-slow: blip_2

This comment contains `run-slow`, running the specified jobs: 

models: ["models/blip_2"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19697001291)

### Model CI Report

#### ❌ Failed tests

- [blip_2](https://github.com/huggingface/transformers/actions/runs/19697001291/job/56424586673):
    tests/models/blip_2/test_modeling_blip_2.py::Blip2ModelIntegrationTest::test_inference_itm
    tests/models/blip_2/test_modeling_blip_2.py::Blip2ModelIntegrationTest::test_inference_itm_fp16




run-slow: blip_2




run-slow: blip_2



Can you also fix the modeling code to be in line with the changes? In some places we check if the model config was updated or not with `if self.config.image_token_index is not None` but after this PR all model inputs will be prepared in "updated" format. So we can assume it safely in modeling code 

It can be later tested with `RUN_SLOW=1 pytest tests/models/blip_2/test_modeling_blip_2.py::Blip2ModelIntegrationTest::test_inference_itm`

Finally, you need to run `make fix-copies` and `make style` to pass the CI checks

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: blip_2

@bot /style

Style fix is beginning .... [View the workflow run here](https://github.com/huggingface/transformers/actions/runs/19931089421).