def preprocess(
        self,
        task_prompt: Union[str, List[str]],
        content_prompt: Union[str, List[str]],
        input_images: Optional[List[List[List[Optional[str]]]]] = None,
        height: Optional[int] = None,
        width: Optional[int] = None,
        upsampling: bool = False,
        vae_scale_factor: int = 16,
    ) -> Dict:
        """Process visual cloze inputs.

        Args:
            task_prompt: Task description(s)
            content_prompt: Content description(s)
            input_images: List of images or None for the target images
            height: Optional target height for upsampling stage
            width: Optional target width for upsampling stage
            upsampling: Whether this is in the upsampling processing stage

        Returns:
            Dictionary containing processed images, masks, prompts and metadata
        """
        if isinstance(task_prompt, str):
            task_prompt = [task_prompt]
            content_prompt = [content_prompt]
            input_images = [input_images]

        output = {
            "init_image": [],
            "mask": [],
            "task_prompt": task_prompt if not upsampling else [None for _ in range(len(task_prompt))],
            "content_prompt": content_prompt,
            "layout_prompt": [],
            "target_position": [],
            "image_size": [],
        }
        for i in range(len(task_prompt)):
            if upsampling:
                layout_prompt = None
            else:
                layout_prompt = self.get_layout_prompt((len(input_images[i]), len(input_images[i][0])))

            if upsampling:
                cur_processed_images, cur_image_size = self.preprocess_image_upsampling(
                    input_images[i], height=height, width=width
                )
                cur_mask = self.preprocess_mask_upsampling(cur_processed_images)
            else:
                cur_processed_images, cur_image_size, cur_target_position = self.preprocess_image(
                    input_images[i], vae_scale_factor=vae_scale_factor
                )
                cur_mask = self.preprocess_mask(cur_processed_images, cur_target_position)

                output["target_position"].append(cur_target_position)

            output["image_size"].append(cur_image_size)
            output["init_image"].append(cur_processed_images)
            output["mask"].append(cur_mask)
            output["layout_prompt"].append(layout_prompt)

        return output
Process visual cloze inputs.

        Args:
            task_prompt: Task description(s)
            content_prompt: Content description(s)
            input_images: List of images or None for the target images
            height: Optional target height for upsampling stage
            width: Optional target width for upsampling stage
            upsampling: Whether this is in the upsampling processing stage

        Returns:
            Dictionary containing processed images, masks, prompts and metadata
        
src/diffusers/pipelines/visualcloze/visualcloze_utils.py