



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 						UpperCAmelCase__     (     __UpperCamelCase		,__UpperCamelCase  ):




			'''simple docstring'''






			def __init__(  self				:					int					):
					'''simple docstring'''





					super().__init__()

					self.register_buffer('''watermark_image'''			,			torch.zeros((62, 62, 4)					)					)
					__UpperCAmelCase       :	Union[str, Any]						=      None




			def 					snake_case__	(  self				:					Union[str, Any]			,			a_				:					List[PIL.Image.Image]			,			a_				:					List[str]=None					):
					'''simple docstring'''





					__UpperCAmelCase       :	Union[str, Any]						=      images[0].height
					__UpperCAmelCase       :	List[Any]						=      images[0].width

					__UpperCAmelCase       :	str						=      sample_size or h

					__UpperCAmelCase       :	Union[str, Any]						=      min(h / sample_size			,			w / sample_size					)
					__UpperCAmelCase				,   __UpperCAmelCase       :	Union[str, Any]						=      (int(h / coef					), int(w / coef					)) if coef < 1 else (h, w)

					__UpperCAmelCase				,   __UpperCAmelCase       :	int						=      10_24**2, img_w * img_h
					__UpperCAmelCase       :	int						=      (Sa / Sa) ** 0.5
					__UpperCAmelCase				,   __UpperCAmelCase				,   __UpperCAmelCase       :	str						=      int(K * 62					), img_w - int(14 * K					), img_h - int(14 * K					)

					if self.watermark_image_as_pil is None:
							__UpperCAmelCase       :	Dict						=      self.watermark_image.to(torch.uinta					).cpu().numpy()
							__UpperCAmelCase       :	str						=      Image.fromarray(a_			,			mode='''RGBA'''					)
							__UpperCAmelCase       :	Dict						=      watermark_image

					__UpperCAmelCase       :	Any						=      self.watermark_image_as_pil.resize(
					    (wm_size, wm_size)			,			PIL_INTERPOLATION['''bicubic''']			,			reducing_gap=a_					)

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

					return images










from typing import TYPE_CHECKING

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


__A       ={
    "configuration_speech_to_text_2": ["SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Speech2Text2Config"],
    "processing_speech_to_text_2": ["Speech2Text2Processor"],
    "tokenization_speech_to_text_2": ["Speech2Text2Tokenizer"],
}


try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A       =[
				    "SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "Speech2Text2ForCausalLM",
				    "Speech2Text2PreTrainedModel",
				]


if TYPE_CHECKING:
				from .configuration_speech_to_text_a import SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextaConfig
				from .processing_speech_to_text_a import SpeechaTextaProcessor
				from .tokenization_speech_to_text_a import SpeechaTextaTokenizer

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_speech_to_text_a import (
								    SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST,
								    SpeechaTextaForCausalLM,
								    SpeechaTextaPreTrainedModel,
								)

else:
				import sys

				__A       =_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





