




from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase__ :   List[str]					=							logging.get_logger(__name__)

lowerCamelCase__ :   List[str]					=							{
    'facebook/s2t-small-librispeech-asr': (
        'https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}





class        lowerCamelCase_							(      _SCREAMING_SNAKE_CASE					):


 '''simple docstring'''







 lowercase_				    =    "speech_to_text"
 lowercase_				    =    ["past_key_values"]
 lowercase_				    =    {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}



 def __init__(							self  :		Tuple				,				_lowerCAmelCase  :		List[Any]=10_000				,				_lowerCAmelCase  :		List[Any]=12				,				_lowerCAmelCase  :		Union[str, Any]=2_048				,				_lowerCAmelCase  :		Optional[int]=4				,				_lowerCAmelCase  :		Union[str, Any]=6				,				_lowerCAmelCase  :		Optional[int]=2_048				,				_lowerCAmelCase  :		Optional[Any]=4				,				_lowerCAmelCase  :		Any=0.0				,				_lowerCAmelCase  :		Optional[Any]=0.0				,				_lowerCAmelCase  :		List[str]=True				,				_lowerCAmelCase  :		List[Any]=True				,				_lowerCAmelCase  :		int="relu"				,				_lowerCAmelCase  :		Union[str, Any]=256				,				_lowerCAmelCase  :		List[str]=0.1				,				_lowerCAmelCase  :		str=0.0				,				_lowerCAmelCase  :		Tuple=0.0				,				_lowerCAmelCase  :		List[str]=0.02				,				_lowerCAmelCase  :		List[str]=2				,				_lowerCAmelCase  :		Tuple=True				,				_lowerCAmelCase  :		List[str]=1				,				_lowerCAmelCase  :		str=0				,				_lowerCAmelCase  :		str=2				,				_lowerCAmelCase  :		Union[str, Any]=6_000				,				_lowerCAmelCase  :		List[str]=1_024				,				_lowerCAmelCase  :		str=2				,				_lowerCAmelCase  :		Optional[Any]=(5, 5)				,				_lowerCAmelCase  :		str=1_024				,				_lowerCAmelCase  :		str=80				,				_lowerCAmelCase  :		Tuple=1				,				**_lowerCAmelCase  :		Any				,				):
       SCREAMING_SNAKE_CASE_							=			vocab_size
       SCREAMING_SNAKE_CASE_							=			d_model
       SCREAMING_SNAKE_CASE_							=			encoder_ffn_dim
       SCREAMING_SNAKE_CASE_							=			encoder_layers
       SCREAMING_SNAKE_CASE_							=			encoder_attention_heads
       SCREAMING_SNAKE_CASE_							=			decoder_ffn_dim
       SCREAMING_SNAKE_CASE_							=			decoder_layers
       SCREAMING_SNAKE_CASE_							=			decoder_attention_heads
       SCREAMING_SNAKE_CASE_							=			dropout
       SCREAMING_SNAKE_CASE_							=			attention_dropout
       SCREAMING_SNAKE_CASE_							=			activation_dropout
       SCREAMING_SNAKE_CASE_							=			activation_function
       SCREAMING_SNAKE_CASE_							=			init_std
       SCREAMING_SNAKE_CASE_							=			encoder_layerdrop
       SCREAMING_SNAKE_CASE_							=			decoder_layerdrop
       SCREAMING_SNAKE_CASE_							=			use_cache
       SCREAMING_SNAKE_CASE_							=			encoder_layers
       SCREAMING_SNAKE_CASE_							=			scale_embedding  # scale factor will be sqrt(d_model) if True
       SCREAMING_SNAKE_CASE_							=			max_source_positions
       SCREAMING_SNAKE_CASE_							=			max_target_positions
       SCREAMING_SNAKE_CASE_							=			num_conv_layers
       SCREAMING_SNAKE_CASE_							=			list(_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			conv_channels
       SCREAMING_SNAKE_CASE_							=			input_feat_per_channel
       SCREAMING_SNAKE_CASE_							=			input_channels

       if len(self.conv_kernel_sizes						) != self.num_conv_layers:
             raise ValueError(
                 'Configuration for convolutional module is incorrect. '
                 'It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` '
                 F"but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes						)}`, "
                 F"`config.num_conv_layers = {self.num_conv_layers}`."						)

       super().__init__(
           pad_token_id=_lowerCAmelCase				,				bos_token_id=_lowerCAmelCase				,				eos_token_id=_lowerCAmelCase				,				is_encoder_decoder=_lowerCAmelCase				,				decoder_start_token_id=_lowerCAmelCase				,				**_lowerCAmelCase				,				)





import unittest

import numpy as np

from diffusers import OnnxStableDiffusionInpaintPipelineLegacy
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    load_numpy,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)


if is_onnx_available():
   import onnxruntime as ort





@nightly
@require_onnxruntime
@require_torch_gpu
class        lowerCamelCase_							(      unittest.TestCase					):


 '''simple docstring'''







 @property
 def       lowerCAmelCase_  (							self  :		Optional[Any]						):
       return (
           "CUDAExecutionProvider",
           {
               "gpu_mem_limit": "15000000000",  # 15GB
               "arena_extend_strategy": "kSameAsRequested",
           },
       )



 @property
 def       lowerCAmelCase_  (							self  :		str						):
       SCREAMING_SNAKE_CASE_							=			ort.SessionOptions()
       SCREAMING_SNAKE_CASE_							=			False
       return options




 def       lowerCAmelCase_  (							self  :		Tuple						):
       SCREAMING_SNAKE_CASE_							=			load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/overture-creations-5sI6fQgYIuo.png'						)
       SCREAMING_SNAKE_CASE_							=			load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/overture-creations-5sI6fQgYIuo_mask.png'						)
       SCREAMING_SNAKE_CASE_							=			load_numpy(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/red_cat_sitting_on_a_park_bench_onnx.npy'						)

       # using the PNDM scheduler by default
       SCREAMING_SNAKE_CASE_							=			OnnxStableDiffusionInpaintPipelineLegacy.from_pretrained(
           'CompVis/stable-diffusion-v1-4'				,				revision='onnx'				,				safety_checker=_lowerCAmelCase				,				feature_extractor=_lowerCAmelCase				,				provider=self.gpu_provider				,				sess_options=self.gpu_options				,				)
       pipe.set_progress_bar_config(disable=_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			'A red cat sitting on a park bench'

       SCREAMING_SNAKE_CASE_							=			np.random.RandomState(0						)
       SCREAMING_SNAKE_CASE_							=			pipe(
           prompt=_lowerCAmelCase				,				image=_lowerCAmelCase				,				mask_image=_lowerCAmelCase				,				strength=0.75				,				guidance_scale=7.5				,				num_inference_steps=15				,				generator=_lowerCAmelCase				,				output_type='np'				,				)

       SCREAMING_SNAKE_CASE_							=			output.images[0]

       assert image.shape == (512, 512, 3)
       assert np.abs(expected_image - image						).max() < 1E-2