





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







  def __init__(		self		)		->    List[Any]:






        """simple docstring"""





        super().__init__()

        self.register_buffer('''watermark_image'''  ,  torch.zeros((62, 62, 4)		)		)
        _snake_case		:						int         =  None







  def 					UpperCAmelCase_					(		self  ,  lowercase__  ,  lowercase__=None		)		->    List[Any]:






        """simple docstring"""





        _snake_case		:						List[str]         =  images[0].height
        _snake_case		:						Any         =  images[0].width

        _snake_case		:						Optional[Any]         =  sample_size or h

        _snake_case		:						Dict         =  min(h / sample_size  ,  w / sample_size		)
        _snake_case  ,				_snake_case		:						str         =  (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		:						Any         =  (Sa / Sa) ** 0.5
        _snake_case  ,				_snake_case  ,				_snake_case		:						List[str]         =  int(K * 62		), img_w - int(14 * K		), img_h - int(14 * K		)

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

        _snake_case		:						Any         =  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









'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


UpperCAmelCase       :		Dict		=				{'configuration_hubert': ['HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'HubertConfig']}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase       :		Union[str, Any]		=				[
       'HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'HubertForCTC',
       'HubertForSequenceClassification',
       'HubertModel',
       'HubertPreTrainedModel',
   ]


try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase       :		Optional[int]		=				[
       'TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TFHubertForCTC',
       'TFHubertModel',
       'TFHubertPreTrainedModel',
   ]

if TYPE_CHECKING:
   from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_hubert import (
          HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          HubertForCTC,
          HubertForSequenceClassification,
          HubertModel,
          HubertPreTrainedModel,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_hubert import (
          TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFHubertForCTC,
          TFHubertModel,
          TFHubertPreTrainedModel,
      )


else:
   import sys

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


