



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


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

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






   def 							lowercase					(				self   :				Union[str, Any],  lowerCAmelCase   :				List[str],  lowerCAmelCase   :				List[Any]=None      )     ->							List[Any]:
         lowercase	:   List[str]											= images[0].height
         lowercase	:   Any											= images[0].width

         lowercase	:   Optional[Any]											= sample_size or h

         lowercase	:   Dict											= min(h / sample_size,  w / sample_size      )
         lowercase	:   str											= (int(h / coef      ), int(w / coef      )) if coef < 1 else (h, w)

         lowercase	:   int											= 1024**2, img_w * img_h
         lowercase	:   Any											= (Sa / Sa) ** 0.5
         lowercase	:   List[str]											= int(K * 62      ), img_w - int(14 * K      ), img_h - int(14 * K      )

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

         lowercase	:   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__)


