



"""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  (      _lowerCAmelCase   ,						_lowerCAmelCase    ):






     '''simple docstring'''





     def __init__(	self:							Optional[int]						)       ->     str:
           super().__init__()

           self.register_buffer("""watermark_image"""						,					torch.zeros((62, 62, 4)						)						)
           snake_case_			:List[Any]						=      None






     def        lowerCAmelCase_    (	self:							Union[str, Any]						,					snake_case:							Optional[int]						,					snake_case:							Optional[Any]=None						)       ->     Optional[Any]:
           snake_case_			:List[Any]						=      images[0].height
           snake_case_			:Tuple						=      images[0].width

           snake_case_			:Any						=      sample_size or h

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

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

           if self.watermark_image_as_pil is None:
                 snake_case_			:List[Any]						=      self.watermark_image.to(torch.uinta						).cpu().numpy()
                 snake_case_			:Union[str, Any]						=      Image.fromarray(snake_case						,					mode="""RGBA"""						)
                 snake_case_			:Dict						=      watermark_image

           snake_case_			:str						=      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





"""simple docstring"""
import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import Mock, patch

import diffusers.utils.hub_utils
class     lowerCamelCase  (      unittest.TestCase    ):






					'''simple docstring'''





					@patch("""diffusers.utils.hub_utils.get_full_repo_name"""						)
					def        lowerCAmelCase_    (	self:							int						,					snake_case:							Mock						)       ->     None:
											snake_case_			:str						=      """full_repo_name"""
											with TemporaryDirectory() as tmpdir:
																	# Dummy args values
																	snake_case_			:int						=      Mock()
																	snake_case_			:Any						=      tmpdir
																	snake_case_			:int						=      0
																	snake_case_			:Optional[int]						=      """hub_token"""
																	snake_case_			:str						=      """dataset_name"""
																	snake_case_			:List[str]						=      0.0_1
																	snake_case_			:Dict						=      100_000
																	snake_case_			:Optional[Any]						=      10_000
																	snake_case_			:Optional[Any]						=      0.0_1
																	snake_case_			:Dict						=      0.0_2
																	snake_case_			:Dict						=      0.0_3
																	snake_case_			:Union[str, Any]						=      0.0_0_0_5
																	snake_case_			:Optional[Any]						=      0.0_0_0_0_0_1
																	snake_case_			:List[Any]						=      1
																	snake_case_			:Optional[Any]						=      10
																	snake_case_			:Dict						=      0.0_0_1
																	snake_case_			:Any						=      0.1
																	snake_case_			:List[Any]						=      0.2
																	snake_case_			:Any						=      True

																	# Model card mush be rendered and saved
																	diffusers.utils.hub_utils.create_model_card(snake_case						,					model_name="""model_name"""						)
																	self.assertTrue((Path(snake_case						) / """README.md""").is_file()						)
