def _prepare_messages(
        self, task: str, image_documents: ImageDocument
    ) -> Dict[str, Any]:
        """
        Prepares the input messages and images for Qwen2 models. Images are appended in a custom format.
        """
        if isinstance(image_documents, list):
            print(
                f"{self.model_name} can handleo only one image. Will continue with the first image."
            )
            image_documents = image_documents[0]
        prompt = (
            task.upper()
            if task.upper()
            in ["<CAPTION>", "<DETAILED_CAPTION>", "<MORE_DETAILED_CAPTION>"]
            else "<DETAILED_CAPTION>"
        )
        images = Image.open(image_documents.image_path)
        inputs = self._processor(text=prompt, images=images, return_tensors="pt").to(
            self.device, self.torch_dtype
        )
        return {
            "prompt": prompt,
            "inputs": inputs,
            "image_size": (images.width, images.height),
        }

        Prepares the input messages and images for Qwen2 models. Images are appended in a custom format.
        
llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-huggingface/llama_index/multi_modal_llms/huggingface/base.py