def preprocess_mask(
        self, input_images: List[List[Image.Image]], target_position: List[int]
    ) -> List[List[torch.Tensor]]:
        """
        Generate masks for the VisualCloze pipeline.

        Args:
            input_images (List[List[Image.Image]]):
                Processed images from preprocess_image
            target_position (List[int]):
                Binary list marking the positions of target images (1 for target, 0 for condition)

        Returns:
            List[List[torch.Tensor]]:
                A nested list of mask tensors (1 for target positions, 0 for condition images)
        """
        mask = []
        for i, row in enumerate(input_images):
            if i == len(input_images) - 1:  # Query row
                row_masks = [
                    torch.full((1, 1, row[0].shape[2], row[0].shape[3]), fill_value=m) for m in target_position
                ]
            else:  # In-context examples
                row_masks = [
                    torch.full((1, 1, row[0].shape[2], row[0].shape[3]), fill_value=0) for _ in target_position
                ]
            mask.append(row_masks)
        return mask

        Generate masks for the VisualCloze pipeline.

        Args:
            input_images (List[List[Image.Image]]):
                Processed images from preprocess_image
            target_position (List[int]):
                Binary list marking the positions of target images (1 for target, 0 for condition)

        Returns:
            List[List[torch.Tensor]]:
                A nested list of mask tensors (1 for target positions, 0 for condition images)
        
src/diffusers/pipelines/visualcloze/visualcloze_utils.py