


'''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 					_A						(						UpperCamelCase    ,  UpperCamelCase							):



   '''simple docstring'''






   def __init__(	self	:					Dict						)->	Dict:
          super().__init__()

          self.register_buffer("""watermark_image"""					, torch.zeros((62, 62, 4)						)						)
          snake_case__					:	Union[str, Any]          =					None




   def   __lowerCAmelCase						(	self	:					str					, lowerCamelCase	:					List[PIL.Image.Image]					, lowerCamelCase	:					List[str]=None						)->	Optional[int]:
          # copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287

          snake_case__					:	int          =					images[0].height
          snake_case__					:	Tuple          =					images[0].width

          snake_case__					:	List[Any]          =					sample_size or h

          snake_case__					:	Any          =					min(h / sample_size					, w / sample_size						)
          snake_case__       ,   snake_case__					:	int          =					(int(h / coef						), int(w / coef						)) if coef < 1 else (h, w)

          snake_case__       ,   snake_case__					:	Dict          =					1_024**2, img_w * img_h
          snake_case__					:	Optional[int]          =					(Sa / Sa) ** 0.5
          snake_case__       ,   snake_case__       ,   snake_case__					:	Any          =					int(K * 62						), img_w - int(14 * K						), img_h - int(14 * K						)

          if self.watermark_image_as_pil is None:
                 snake_case__					:	int          =					self.watermark_image.to(torch.uinta						).cpu().numpy()
                 snake_case__					:	List[str]          =					Image.fromarray(lowerCamelCase					, mode="""RGBA"""						)
                 snake_case__					:	Any          =					watermark_image

          snake_case__					:	Optional[Any]          =					self.watermark_image_as_pil.resize(
              (wm_size, wm_size)					, PIL_INTERPOLATION["""bicubic"""]					, reducing_gap=lowerCamelCase						)

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

          return images








'''simple docstring'''
import unittest
from timeit import timeit



def 				lowerCAmelCase__	(       UpperCAmelCase    ,       UpperCAmelCase     ):






       """simple docstring"""





       snake_case__					:	Any          =					first_num if first_num >= second_num else second_num
       snake_case__					:	Optional[Any]          =					max_num
       while (common_mult % first_num > 0) or (common_mult % second_num > 0):
              common_mult += max_num
       return common_mult



def 				lowerCAmelCase__	(       UpperCAmelCase    ,       UpperCAmelCase     ):






       """simple docstring"""





       return b if a == 0 else greatest_common_divisor(b % a    ,       UpperCAmelCase     )



def 				lowerCAmelCase__	(       UpperCAmelCase    ,       UpperCAmelCase     ):






       """simple docstring"""





       return first_num // greatest_common_divisor(UpperCAmelCase    ,       UpperCAmelCase     ) * second_num



def 				lowerCAmelCase__	(       ):






       """simple docstring"""





       snake_case__					:	Tuple          =					(
           """from __main__ import least_common_multiple_slow, least_common_multiple_fast"""
       )
       print(
           """least_common_multiple_slow():"""    ,       timeit("""least_common_multiple_slow(1000, 999)"""    ,       setup=UpperCAmelCase     )    ,       )
       print(
           """least_common_multiple_fast():"""    ,       timeit("""least_common_multiple_fast(1000, 999)"""    ,       setup=UpperCAmelCase     )    ,       )







class 					_A						(						unittest.TestCase							):



   '''simple docstring'''






   _lowercase    						= (
       (10, 20),
       (13, 15),
       (4, 31),
       (10, 42),
       (43, 34),
       (5, 12),
       (12, 25),
       (10, 25),
       (6, 9),
   )
   _lowercase    						= (20, 195, 124, 210, 1462, 60, 300, 50, 18)




   def   __lowerCAmelCase						(	self	:					Optional[int]						)->	Optional[Any]:
          for i, (first_num, second_num) in enumerate(self.test_inputs						):
                 snake_case__					:	List[Any]          =					least_common_multiple_slow(lowerCamelCase					, lowerCamelCase						)
                 snake_case__					:	Optional[Any]          =					least_common_multiple_fast(lowerCamelCase					, lowerCamelCase						)
                 with self.subTest(i=lowerCamelCase						):
                        self.assertEqual(lowerCamelCase					, self.expected_results[i]						)
                        self.assertEqual(lowerCamelCase					, self.expected_results[i]						)


if __name__ == "__main__":
     benchmark()
     unittest.main()




