

"""simple docstring"""






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       ):

							def __init__( self       :    Optional[Any]    )   ->    Union[str, Any]:

									"""simple docstring"""
									super().__init__()

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

							def 					_lowerCAmelCase  ( self       :    Any ,		a       :    List[PIL.Image.Image] ,		a       :    Tuple=None    )   ->    List[Any]:

									"""simple docstring"""
									# copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287

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

									lowercase										=							sample_size or h

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

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

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

									lowercase										=							self.watermark_image_as_pil.resize(
									    (wm_size, wm_size) ,		PIL_INTERPOLATION['''bicubic'''] ,		reducing_gap=a    )

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

									return images


"""simple docstring"""






from ..utils import DummyObject, requires_backends
class 	_lowerCAmelCase    (      metaclass=__snake_case       ):
							__lowerCAmelCase					:    Optional[Any]     =  ['''tensorflow_text''']

							def __init__( self       :    Optional[int] ,		*a       :    int ,		**a       :    str    )   ->    str:

									"""simple docstring"""
									requires_backends(self ,		['''tensorflow_text''']    )