
'''simple docstring'''
from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_DEFAULT_MEAN,
    IMAGENET_DEFAULT_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
						import PIL


lowercase__		    =	logging.get_logger(__name__)






class      snake_case__    (	__SCREAMING_SNAKE_CASE ):







		"""simple docstring"""

		lowerCamelCase							=		["""pixel_values"""]



		def __init__(	self							:       List[str]   ,     UpperCamelCase__							:       bool = True   ,     UpperCamelCase__							:       Dict[str, int] = None   ,     UpperCamelCase__							:       bool = True   ,     UpperCamelCase__							:       Dict[str, int] = None   ,     UpperCamelCase__							:       PILImageResampling = PILImageResampling.BICUBIC   ,     UpperCamelCase__							:       bool = True   ,     UpperCamelCase__							:       Union[int, float] = 1 / 255   ,     UpperCamelCase__							:       bool = True   ,     UpperCamelCase__							:       Optional[Union[float, List[float]]] = None   ,     UpperCamelCase__							:       Optional[Union[float, List[float]]] = None   ,     **UpperCamelCase__							:       List[Any]   ,     )		->       None:






				"""simple docstring"""







				super().__init__(**UpperCamelCase__	)
				snake_case   :    int			       =		crop_size if crop_size is not None else {'''height''': 256, '''width''': 256}
				snake_case   :    List[str]			       =		get_size_dict(UpperCamelCase__   ,     param_name='''crop_size'''	)
				snake_case   :    int			       =		size if size is not None else {'''height''': 224, '''width''': 224}
				snake_case   :    List[str]			       =		get_size_dict(UpperCamelCase__	)

				snake_case   :    List[Any]			       =		do_center_crop
				snake_case   :    Dict			       =		crop_size
				snake_case   :    Tuple			       =		do_resize
				snake_case   :    Tuple			       =		size
				snake_case   :    Tuple			       =		resample
				snake_case   :    Optional[int]			       =		do_rescale
				snake_case   :    Dict			       =		rescale_factor
				snake_case   :    Any			       =		do_normalize
				snake_case   :    int			       =		image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
				snake_case   :    Tuple			       =		image_std if image_std is not None else IMAGENET_DEFAULT_STD



		def 	lowerCAmelCase							(	self							:       Optional[Any]   ,     UpperCamelCase__							:       np.ndarray   ,     UpperCamelCase__							:       Dict[str, int]   ,     UpperCamelCase__							:       Optional[int] = None   ,     UpperCamelCase__							:       Optional[Union[str, ChannelDimension]] = None   ,     **UpperCamelCase__							:       Tuple   ,     )		->       np.ndarray:






				"""simple docstring"""







				snake_case   :    Any			       =		self.size if size is None else size
				snake_case   :    List[Any]			       =		get_size_dict(UpperCamelCase__	)
				snake_case   :    int			       =		get_size_dict(UpperCamelCase__   ,     param_name='''crop_size'''	)

				snake_case       ,snake_case   :    Any			       =		get_image_size(UpperCamelCase__	)
				snake_case   :    Union[str, Any]			       =		min(UpperCamelCase__   ,     UpperCamelCase__	)
				snake_case   :    Optional[int]			       =		(size['''height'''] / crop_size['''height''']) * min_dim
				snake_case   :    List[str]			       =		(size['''width'''] / crop_size['''width''']) * min_dim
				return center_crop(UpperCamelCase__   ,     size=(cropped_height, cropped_width)   ,     data_format=UpperCamelCase__   ,     **UpperCamelCase__	)



		def 	lowerCAmelCase							(	self							:       str   ,     UpperCamelCase__							:       np.ndarray   ,     UpperCamelCase__							:       Dict[str, int]   ,     UpperCamelCase__							:       PILImageResampling = PIL.Image.BICUBIC   ,     UpperCamelCase__							:       Optional[Union[str, ChannelDimension]] = None   ,     **UpperCamelCase__							:       Optional[int]   ,     )		->       np.ndarray:






				"""simple docstring"""







				snake_case   :    str			       =		get_size_dict(UpperCamelCase__	)
				if "height" not in size or "width" not in size:
						raise ValueError(f'The size dictionary must contain the keys \'height\' and \'width\'. Got {size.keys()}'	)
				return resize(
				    UpperCamelCase__   ,     size=(size['''height'''], size['''width'''])   ,     resample=UpperCamelCase__   ,     data_format=UpperCamelCase__   ,     **UpperCamelCase__	)



		def 	lowerCAmelCase							(	self							:       Optional[Any]   ,     UpperCamelCase__							:       np.ndarray   ,     UpperCamelCase__							:       Union[int, float]   ,     UpperCamelCase__							:       Optional[Union[str, ChannelDimension]] = None   ,     **UpperCamelCase__							:       int   ,     )		->       Tuple:






				"""simple docstring"""







				return rescale(UpperCamelCase__   ,     scale=UpperCamelCase__   ,     data_format=UpperCamelCase__   ,     **UpperCamelCase__	)



		def 	lowerCAmelCase							(	self							:       List[Any]   ,     UpperCamelCase__							:       np.ndarray   ,     UpperCamelCase__							:       Union[float, List[float]]   ,     UpperCamelCase__							:       Union[float, List[float]]   ,     UpperCamelCase__							:       Optional[Union[str, ChannelDimension]] = None   ,     **UpperCamelCase__							:       int   ,     )		->       np.ndarray:






				"""simple docstring"""







				return normalize(UpperCamelCase__   ,     mean=UpperCamelCase__   ,     std=UpperCamelCase__   ,     data_format=UpperCamelCase__   ,     **UpperCamelCase__	)



		def 	lowerCAmelCase							(	self							:       Tuple   ,     UpperCamelCase__							:       ImageInput   ,     UpperCamelCase__							:       Optional[bool] = None   ,     UpperCamelCase__							:       Optional[Dict[str, int]] = None   ,     UpperCamelCase__							:       Optional[bool] = None   ,     UpperCamelCase__							:       Optional[Dict[str, int]] = None   ,     UpperCamelCase__							:       PILImageResampling = None   ,     UpperCamelCase__							:       Optional[bool] = None   ,     UpperCamelCase__							:       Optional[float] = None   ,     UpperCamelCase__							:       Optional[bool] = None   ,     UpperCamelCase__							:       Optional[Union[float, List[float]]] = None   ,     UpperCamelCase__							:       Optional[Union[float, List[float]]] = None   ,     UpperCamelCase__							:       Optional[Union[str, TensorType]] = None   ,     UpperCamelCase__							:       ChannelDimension = ChannelDimension.FIRST   ,     **UpperCamelCase__							:       Any   ,     )		->       PIL.Image.Image:






				"""simple docstring"""







				snake_case   :    int			       =		do_center_crop if do_center_crop is not None else self.do_center_crop
				snake_case   :    Optional[int]			       =		crop_size if crop_size is not None else self.crop_size
				snake_case   :    Optional[Any]			       =		get_size_dict(UpperCamelCase__   ,     param_name='''crop_size'''	)
				snake_case   :    Tuple			       =		do_resize if do_resize is not None else self.do_resize
				snake_case   :    Tuple			       =		size if size is not None else self.size
				snake_case   :    Union[str, Any]			       =		get_size_dict(UpperCamelCase__	)
				snake_case   :    str			       =		resample if resample is not None else self.resample
				snake_case   :    Optional[int]			       =		do_rescale if do_rescale is not None else self.do_rescale
				snake_case   :    int			       =		rescale_factor if rescale_factor is not None else self.rescale_factor
				snake_case   :    Tuple			       =		do_normalize if do_normalize is not None else self.do_normalize
				snake_case   :    Any			       =		image_mean if image_mean is not None else self.image_mean
				snake_case   :    str			       =		image_std if image_std is not None else self.image_std

				snake_case   :    Tuple			       =		make_list_of_images(UpperCamelCase__	)

				if not valid_images(UpperCamelCase__	):
						raise ValueError(
						    '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
						    '''torch.Tensor, tf.Tensor or jax.ndarray.'''	)

				if do_center_crop and crop_size is None:
						raise ValueError('''If `do_center_crop` is set to `True`, `crop_size` must be provided.'''	)

				if do_resize and size is None:
						raise ValueError('''Size must be specified if do_resize is True.'''	)

				if do_rescale and rescale_factor is None:
						raise ValueError('''Rescale factor must be specified if do_rescale is True.'''	)

				if do_normalize and (image_mean is None or image_std is None):
						raise ValueError('''Image mean and image standard deviation must be specified if do_normalize is True.'''	)

				# All transformations expect numpy arrays.
				snake_case   :    str			       =		[to_numpy_array(UpperCamelCase__	) for image in images]

				if do_center_crop:
						snake_case   :    Union[str, Any]			       =		[self.center_crop(UpperCamelCase__   ,     UpperCamelCase__   ,     size=UpperCamelCase__	) for image in images]

				if do_resize:
						snake_case   :    int			       =		[self.resize(image=UpperCamelCase__   ,     size=UpperCamelCase__   ,     resample=UpperCamelCase__	) for image in images]

				if do_rescale:
						snake_case   :    Optional[int]			       =		[self.rescale(image=UpperCamelCase__   ,     scale=UpperCamelCase__	) for image in images]

				if do_normalize:
						snake_case   :    Optional[Any]			       =		[self.normalize(image=UpperCamelCase__   ,     mean=UpperCamelCase__   ,     std=UpperCamelCase__	) for image in images]

				snake_case   :    List[Any]			       =		[to_channel_dimension_format(UpperCamelCase__   ,     UpperCamelCase__	) for image in images]

				snake_case   :    Optional[int]			       =		{'''pixel_values''': images}
				return BatchFeature(data=UpperCamelCase__   ,     tensor_type=UpperCamelCase__	)




'''simple docstring'''
from __future__ import annotations

import sys




def 					_UpperCamelCase		(    SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__       )   ->				tuple[int, int]:


		'''simple docstring'''


		if abs(SCREAMING_SNAKE_CASE__       ) == 1:
				return a, 0
		elif abs(SCREAMING_SNAKE_CASE__       ) == 1:
				return 0, b

		snake_case       ,snake_case   :    Tuple			       =		a, b
		snake_case       ,snake_case   :    List[str]			       =		1, 0
		snake_case       ,snake_case   :    Optional[Any]			       =		0, 1

		while remainder != 0:
				snake_case   :    int			       =		old_remainder // remainder
				snake_case       ,snake_case   :    Tuple			       =		remainder, old_remainder - quotient * remainder
				snake_case       ,snake_case   :    Optional[Any]			       =		coeff_a, old_coeff_a - quotient * coeff_a
				snake_case       ,snake_case   :    Dict			       =		coeff_b, old_coeff_b - quotient * coeff_b

		# sign correction for negative numbers
		if a < 0:
				snake_case   :    Optional[Any]			       =		-old_coeff_a
		if b < 0:
				snake_case   :    int			       =		-old_coeff_b

		return old_coeff_a, old_coeff_b




def 					_UpperCamelCase		(    )   ->				str:


		'''simple docstring'''


		if len(sys.argv       ) < 3:
				print('''2 integer arguments required'''       )
				return 1
		snake_case   :    str			       =		int(sys.argv[1]       )
		snake_case   :    List[str]			       =		int(sys.argv[2]       )
		print(extended_euclidean_algorithm(SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__       )       )
		return 0


if __name__ == "__main__":
						raise SystemExit(main())


