




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 							__SCREAMING_SNAKE_CASE				(						lowerCamelCase  ,	lowerCamelCase    ):

					def __init__(							self   ):







						'''simple docstring'''




						super().__init__()

						self.register_buffer('watermark_image'					,			torch.zeros((62, 62, 4)   )   )
						lowerCamelCase_				:						Any				  =				None





					def       lowercase_				(							self					,			__lowercase					,			__lowercase=None   ):







						'''simple docstring'''




						lowerCamelCase_				:						Tuple				  =				images[0].height
						lowerCamelCase_				:						List[Any]				  =				images[0].width

						lowerCamelCase_				:						Tuple				  =				sample_size or h

						lowerCamelCase_				:						List[str]				  =				min(h / sample_size					,			w / sample_size   )
						lowerCamelCase_  ,     lowerCamelCase_				:						int				  =				(int(h / coef   ), int(w / coef   )) if coef < 1 else (h, w)

						lowerCamelCase_  ,     lowerCamelCase_				:						List[Any]				  =				1_024**2, img_w * img_h
						lowerCamelCase_				:						List[str]				  =				(Sa / Sa) ** 0.5
						lowerCamelCase_  ,     lowerCamelCase_  ,     lowerCamelCase_				:						str				  =				int(K * 62   ), img_w - int(14 * K   ), img_h - int(14 * K   )

						if self.watermark_image_as_pil is None:
							lowerCamelCase_				:						Dict				  =				self.watermark_image.to(torch.uinta   ).cpu().numpy()
							lowerCamelCase_				:						str				  =				Image.fromarray(__lowercase					,			mode='RGBA'   )
							lowerCamelCase_				:						Optional[Any]				  =				watermark_image

						lowerCamelCase_				:						Tuple				  =				self.watermark_image_as_pil.resize(
						    (wm_size, wm_size)					,			PIL_INTERPOLATION['bicubic']					,			reducing_gap=__lowercase   )

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

						return images







def        __SCREAMING_SNAKE_CASE	(				__lowercase:		int):



  '''simple docstring'''






  if not isinstance(__lowercase  ,				__lowercase):
    __lowerCAmelCase								=					F'''Input value of [number={number}] must be an integer'''
    raise TypeError(__lowercase)
  if number < 0 or number % 2 == 1:
    return False
  __lowerCAmelCase								=					int(number**0.5)
  return number == number_sqrt * (number_sqrt + 1)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
