


import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey

class 		__a				:
		def __init__(      self      ,   _SCREAMING_SNAKE_CASE      ,   _SCREAMING_SNAKE_CASE      ,   _SCREAMING_SNAKE_CASE						)			->	Tuple:




									"""simple docstring"""





									if dst_width < 0 or dst_height < 0:
																raise ValueError('Destination width/height should be > 0'						)

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

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

									_UpperCAmelCase					=      _UpperCAmelCase					=      (
									    np.ones((self.dst_h, self.dst_w, 3)      ,   np.uinta						) * 255
									)
		def      UpperCAmelCase__    (      self						)			->	Union[str, Any]:




									"""simple docstring"""





									for i in range(self.dst_h						):
																for j in range(self.dst_w						):
																							_UpperCAmelCase					=      self.img[self.get_y(_SCREAMING_SNAKE_CASE						)][self.get_x(_SCREAMING_SNAKE_CASE						)]
		def      UpperCAmelCase__    (      self      ,   _SCREAMING_SNAKE_CASE						)			->	int:




									"""simple docstring"""





									return int(self.ratio_x * x						)






		def      UpperCAmelCase__    (      self      ,   _SCREAMING_SNAKE_CASE						)			->	int:




									"""simple docstring"""





									return int(self.ratio_y * y						)


if __name__ == "__main__":
		lowerCAmelCase__      ,  lowerCAmelCase__  :Any             =							8_0_0, 6_0_0
		lowerCAmelCase__  :List[Any]             =							imread('''image_data/lena.jpg''', 1)
		lowerCAmelCase__  :Optional[int]             =							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()




import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin

class 		__a				(    UpperCAmelCase      ):
		_a     :  Optional[int]           =     'MCTCTFeatureExtractor'
		_a     :  int           =     'AutoTokenizer'
		def __init__(      self      ,   _SCREAMING_SNAKE_CASE      ,   _SCREAMING_SNAKE_CASE						)			->	List[str]:




									"""simple docstring"""





									super().__init__(_SCREAMING_SNAKE_CASE      ,   _SCREAMING_SNAKE_CASE						)
									_UpperCAmelCase					=      self.feature_extractor
									_UpperCAmelCase					=      False
		def __call__(      self      ,   *_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)			->	Tuple:




									"""simple docstring"""





									if self._in_target_context_manager:
																return self.current_processor(*_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)

									if "raw_speech" in kwargs:
																warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'						)
																_UpperCAmelCase					=      kwargs.pop('raw_speech'						)
									else:
																_UpperCAmelCase					=      kwargs.pop('audio'      ,   _SCREAMING_SNAKE_CASE						)
									_UpperCAmelCase					=      kwargs.pop('sampling_rate'      ,   _SCREAMING_SNAKE_CASE						)
									_UpperCAmelCase					=      kwargs.pop('text'      ,   _SCREAMING_SNAKE_CASE						)
									if len(_SCREAMING_SNAKE_CASE						) > 0:
																_UpperCAmelCase					=      args[0]
																_UpperCAmelCase					=      args[1:]

									if audio is None and text is None:
																raise ValueError('You need to specify either an `audio` or `text` input to process.'						)

									if audio is not None:
																_UpperCAmelCase					=      self.feature_extractor(_SCREAMING_SNAKE_CASE      ,   *_SCREAMING_SNAKE_CASE      ,   sampling_rate=_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)
									if text is not None:
																_UpperCAmelCase					=      self.tokenizer(_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)

									if text is None:
																return inputs
									elif audio is None:
																return encodings
									else:
																_UpperCAmelCase					=      encodings['input_ids']
																return inputs
		def      UpperCAmelCase__    (      self      ,   *_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)			->	Optional[int]:




									"""simple docstring"""





									return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)
		def      UpperCAmelCase__    (      self      ,   *_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)			->	str:




									"""simple docstring"""





									if self._in_target_context_manager:
																return self.current_processor.pad(*_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)

									_UpperCAmelCase					=      kwargs.pop('input_features'      ,   _SCREAMING_SNAKE_CASE						)
									_UpperCAmelCase					=      kwargs.pop('labels'      ,   _SCREAMING_SNAKE_CASE						)
									if len(_SCREAMING_SNAKE_CASE						) > 0:
																_UpperCAmelCase					=      args[0]
																_UpperCAmelCase					=      args[1:]

									if input_features is not None:
																_UpperCAmelCase					=      self.feature_extractor.pad(_SCREAMING_SNAKE_CASE      ,   *_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)
									if labels is not None:
																_UpperCAmelCase					=      self.tokenizer.pad(_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)

									if labels is None:
																return input_features
									elif input_features is None:
																return labels
									else:
																_UpperCAmelCase					=      labels['input_ids']
																return input_features
		def      UpperCAmelCase__    (      self      ,   *_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)			->	int:




									"""simple docstring"""





									return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE      ,   **_SCREAMING_SNAKE_CASE						)






		@contextmanager
		def      UpperCAmelCase__    (      self						)			->	Optional[Any]:




									"""simple docstring"""





									warnings.warn(
									    '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
									    'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
									    'your audio inputs, or in a separate call.'						)
									_UpperCAmelCase					=      True
									_UpperCAmelCase					=      self.tokenizer
									yield
									_UpperCAmelCase					=      self.feature_extractor
									_UpperCAmelCase					=      False
