


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





      '''simple docstring'''






      def __init__(self   :   int			):

             '''simple docstring'''







             super().__init__()

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






      def 				UpperCamelCase__		(self   :   Optional[int]       ,						UpperCamelCase   :   List[PIL.Image.Image]       ,						UpperCamelCase   :   Optional[int]=None			):

             '''simple docstring'''







             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(UpperCamelCase       ,						mode='''RGBA'''			)
                    lowercase__				      =			watermark_image

             lowercase__				      =			self.watermark_image_as_pil.resize(
                 (wm_size, wm_size)       ,						PIL_INTERPOLATION['''bicubic''']       ,						reducing_gap=UpperCamelCase			)

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

             return images








'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCamelCase							:       str  						=     {'configuration_nat': ['NAT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NatConfig']}


try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase							:       Tuple  						=     [
     'NAT_PRETRAINED_MODEL_ARCHIVE_LIST',
     'NatForImageClassification',
     'NatModel',
     'NatPreTrainedModel',
     'NatBackbone',
 ]

if TYPE_CHECKING:
 from .configuration_nat import NAT_PRETRAINED_CONFIG_ARCHIVE_MAP, NatConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_nat import (
      NAT_PRETRAINED_MODEL_ARCHIVE_LIST,
      NatBackbone,
      NatForImageClassification,
      NatModel,
      NatPreTrainedModel,
  )

else:
 import sys

 lowerCamelCase							:       Optional[Any]  						=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




