






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


_UpperCAmelCase			:		Tuple   				=    logging.get_logger(__name__)

_UpperCAmelCase			:		Any   				=    {
    "facebook/s2t-wav2vec2-large-en-de": (
        "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json"
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}
class  lowerCAmelCase_       (				snake_case__					):
							UpperCamelCase_		:List[Any]		      =    'speech_to_text_2'
							UpperCamelCase_		:Optional[Any]		      =    ['past_key_values']
							UpperCamelCase_		:Any		      =    {'num_attention_heads': 'decoder_attention_heads', 'hidden_size': 'd_model'}




							def __init__(   self     :   int ,							SCREAMING_SNAKE_CASE_     :   Any=10_000 ,							SCREAMING_SNAKE_CASE_     :   List[str]=6 ,							SCREAMING_SNAKE_CASE_     :   Tuple=2_048 ,							SCREAMING_SNAKE_CASE_     :   List[str]=4 ,							SCREAMING_SNAKE_CASE_     :   Optional[int]=0.0 ,							SCREAMING_SNAKE_CASE_     :   Any=True ,							SCREAMING_SNAKE_CASE_     :   Union[str, Any]="relu" ,							SCREAMING_SNAKE_CASE_     :   Optional[int]=256 ,							SCREAMING_SNAKE_CASE_     :   Optional[int]=0.1 ,							SCREAMING_SNAKE_CASE_     :   Tuple=0.0 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any]=0.0 ,							SCREAMING_SNAKE_CASE_     :   Any=0.02 ,							SCREAMING_SNAKE_CASE_     :   Tuple=2 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any]=True ,							SCREAMING_SNAKE_CASE_     :   Union[str, Any]=1 ,							SCREAMING_SNAKE_CASE_     :   Tuple=0 ,							SCREAMING_SNAKE_CASE_     :   Tuple=2 ,							SCREAMING_SNAKE_CASE_     :   Tuple=1_024 ,							**SCREAMING_SNAKE_CASE_     :   Tuple ,							):
											lowerCAmelCase__      			=						vocab_size
											lowerCAmelCase__      			=						d_model
											lowerCAmelCase__      			=						decoder_ffn_dim
											lowerCAmelCase__      			=						decoder_layers
											lowerCAmelCase__      			=						decoder_attention_heads
											lowerCAmelCase__      			=						dropout
											lowerCAmelCase__      			=						attention_dropout
											lowerCAmelCase__      			=						activation_dropout
											lowerCAmelCase__      			=						activation_function
											lowerCAmelCase__      			=						init_std
											lowerCAmelCase__      			=						decoder_layerdrop
											lowerCAmelCase__      			=						use_cache
											lowerCAmelCase__      			=						decoder_layers
											lowerCAmelCase__      			=						scale_embedding  # scale factor will be sqrt(d_model) if True
											lowerCAmelCase__      			=						max_target_positions

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













import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey
class  lowerCAmelCase_       :




							def __init__(   self     :   Union[str, Any] ,							SCREAMING_SNAKE_CASE_     :   Optional[Any] ,							SCREAMING_SNAKE_CASE_     :   int ,							SCREAMING_SNAKE_CASE_     :   int	):
											if dst_width < 0 or dst_height < 0:
															raise ValueError('''Destination width/height should be > 0'''	)

											lowerCAmelCase__      			=						img
											lowerCAmelCase__      			=						img.shape[1]
											lowerCAmelCase__      			=						img.shape[0]
											lowerCAmelCase__      			=						dst_width
											lowerCAmelCase__      			=						dst_height

											lowerCAmelCase__      			=						self.src_w / self.dst_w
											lowerCAmelCase__      			=						self.src_h / self.dst_h

											lowerCAmelCase__      			=						lowerCAmelCase__      			=						(
											    np.ones((self.dst_h, self.dst_w, 3) ,							np.uinta	) * 255
											)




							def 						__snake_case					(   self     :   List[str]	):
											for i in range(self.dst_h	):
															for j in range(self.dst_w	):
																			lowerCAmelCase__      			=						self.img[self.get_y(SCREAMING_SNAKE_CASE_	)][self.get_x(SCREAMING_SNAKE_CASE_	)]




							def 						__snake_case					(   self     :   Any ,							SCREAMING_SNAKE_CASE_     :   int	):
											return int(self.ratio_x * x	)




							def 						__snake_case					(   self     :   List[str] ,							SCREAMING_SNAKE_CASE_     :   int	):
											return int(self.ratio_y * y	)


if __name__ == "__main__":
			_UpperCAmelCase				,   _UpperCAmelCase			:		List[str]   				=    800, 600
			_UpperCAmelCase			:		Tuple   				=    imread("image_data/lena.jpg", 1)
			_UpperCAmelCase			:		str   				=    NearestNeighbour(im, dst_w, dst_h)
			n.process()

			imshow(
			    F'''Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}''', n.output
			)
			waitKey(0)
			destroyAllWindows()





