src/transformers/pipelines/image_to_text.py/ImageToTextPipeline/_sanitize_parameters
class ImageToTextPipeline:    def _sanitize_parameters(self, max_new_tokens=None, generate_kwargs=None):
        forward_kwargs = {}
        if generate_kwargs is not None:
            forward_kwargs["generate_kwargs"] = generate_kwargs
        if max_new_tokens is not None:
            if "generate_kwargs" not in forward_kwargs:
                forward_kwargs["generate_kwargs"] = {}
            if "max_new_tokens" in forward_kwargs["generate_kwargs"]:
                raise ValueError(
                    "'max_new_tokens' is defined twice, once in 'generate_kwargs' and once as a direct parameter,"
                    " please use only one"
                )
            forward_kwargs["generate_kwargs"]["max_new_tokens"] = max_new_tokens
        return {}, forward_kwargs, {}