fix: cast input pixels to appropriate dtype for image_to_text pipelines
Author: JimAllanson
Pull request: yes

# What does this PR do?
### _Automatically converts input pixels to the correct type when running image_to_text pipelines_

---

Currently, when using image_to_text pipelines with half precision, I encounter an error in the forward function when passing in the pixel data. I found that casting to the target_dtype within the forward function fixes this issue in my case.

This is my first time working with the transformers library, so I'm not sure if this is the "correct" place to fix this kind of issue, or if perhaps there's another step in the pipeline code that I've missed that should be responsible for casting the input data to the correct type.

I assume there are other similar models that may benefit from the same type of fix. However, I've constrained my fix to the models that I've been working with already, as I didn't want to contribute unvalidated code. I'm happy to make similar changes to further models if required, or if someone with more experience with this library wants to rework these changes and approach the fix differently, I'd be happy with that, and can test with the subset of models I've been using if required.

- _Possibly_ Fixes #24834

_(This issue looked similar to the issue I was encountering, however I had different additional issues using 8bit optimizations, so I've only tested my fix under float16. But I think given that issue seems to relate to the same root cause of missing casting for input data within pipelines, I think there's a good chance it may be fixed by this issue.)_

PR Checklist Notes
- I haven't been able to run tests as I ran into dependency issues on my local environment, and the CI workflows appear to use self hosted runners, which I assume won't be easy for me to set up. Given the small scope of my changes, perhaps someone can approve running my PR against CircleCI if necessary?
- I haven't added new tests for this change, I had a read through of the existing tests and I wasn't sure if this sort of low level change would usually warrant explicit test coverage. Since I don't currently have a good way of running the tests myself, I figured it was best to omit new tests for now.

Tagging @younesbelkada and @NielsRogge as the last authors of the lines I edited.

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Thanks, I've run the styling and copy checks locally, which identified some copy checks that were failing. If I understand correctly, these checks are ensuring that the implementations of derived model classes match their sources? On that basis, I've gone ahead and added the same type casting to the classes identified, and pushed a commit with those in. It looks like all of the CI checks are passing now.

> Usually we advise users to cast the input to the desired dtype manually by calling .to() to the processor's output

In my case, I'm currently using transformers via the AWS Deep Learning Containers, using Sagemaker. I've made a small tweak to the entrypoint to allow passing the `torch_dtype` into the pipeline kwargs, but otherwise I was trying to keep my modified container as generic as possible to aid maintainability.