



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







   def __init__(self				):




      '''simple docstring'''




      super().__init__()

      self.register_buffer("""watermark_image"""       ,	torch.zeros((62, 62, 4)				)				)
      _lowerCAmelCase					     =		None







   def 							A__						(self       ,	lowerCamelCase       ,	lowerCamelCase=None				):




      '''simple docstring'''




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

      _lowerCAmelCase					     =		sample_size or h

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

      _lowerCAmelCase					     =		1_024**2, img_w * img_h
      _lowerCAmelCase					     =		(Sa / Sa) ** 0.5
      _lowerCAmelCase					     =		int(K * 62				), img_w - int(14 * K				), img_h - int(14 * K				)

      if self.watermark_image_as_pil is None:
         _lowerCAmelCase					     =		self.watermark_image.to(torch.uinta				).cpu().numpy()
         _lowerCAmelCase					     =		Image.fromarray(lowerCamelCase       ,	mode="""RGBA"""				)
         _lowerCAmelCase					     =		watermark_image

      _lowerCAmelCase					     =		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"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


SCREAMING_SNAKE_CASE				:     Union[str, Any]          =	{
    '''configuration_align''': [
        '''ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''AlignConfig''',
        '''AlignTextConfig''',
        '''AlignVisionConfig''',
    ],
    '''processing_align''': ['''AlignProcessor'''],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE				:     Any          =	[
      '''ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''AlignModel''',
      '''AlignPreTrainedModel''',
      '''AlignTextModel''',
      '''AlignVisionModel''',
  ]

if TYPE_CHECKING:
  from .configuration_align import (
      ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP,
      AlignConfig,
      AlignTextConfig,
      AlignVisionConfig,
  )
  from .processing_align import AlignProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_align import (
        ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST,
        AlignModel,
        AlignPreTrainedModel,
        AlignTextModel,
        AlignVisionModel,
    )

else:
  import sys

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