





from typing import List

import PIL
import torch
from PIL import Image

from ...configuration_utils import ConfigMixin
from ...models.modeling_utils import ModelMixin
from ...utils import PIL_INTERPOLATION







class     lowerCamelCase(	__snake_case ,   __snake_case  ):
     '''simple docstring'''


     def __init__(						self       ):
         super().__init__()

         self.register_buffer('watermark_image'							,    torch.zeros((62, 62, 4)       )       )
         _A    =       None




     def 					lowerCAmelCase__		(						self							,    snake_case_							,    snake_case_=None       ):
         # copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287

         _A    =       images[0].height
         _A    =       images[0].width

         _A    =       sample_size or h

         _A    =       min(h / sample_size							,    w / sample_size       )
         _A, _A    =       (int(h / coef       ), int(w / coef       )) if coef < 1 else (h, w)

         _A, _A    =       1024**2, img_w * img_h
         _A    =       (Sa / Sa) ** 0.5
         _A, _A, _A    =       int(K * 62       ), img_w - int(14 * K       ), img_h - int(14 * K       )

         if self.watermark_image_as_pil is None:
             _A    =       self.watermark_image.to(torch.uinta       ).cpu().numpy()
             _A    =       Image.fromarray(snake_case_							,    mode='RGBA'       )
             _A    =       watermark_image

         _A    =       self.watermark_image_as_pil.resize(
             (wm_size, wm_size)							,    PIL_INTERPOLATION['bicubic']							,    reducing_gap=snake_case_       )

         for pil_img in images:
             pil_img.paste(snake_case_							,    box=(wm_x - wm_size, wm_y - wm_size, wm_x, wm_y)							,    mask=wm_img.split()[-1]       )

         return images












from ..utils import DummyObject, requires_backends


__A       : str						    = None





def 							__lowerCAmelCase(					*_SCREAMING_SNAKE_CASE       ,    **_SCREAMING_SNAKE_CASE							)       ->   Tuple:




    """simple docstring"""




    requires_backends(_SCREAMING_SNAKE_CASE       ,    ['sentencepiece', 'tokenizers']							)





