

'''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,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
					import PIL


lowerCAmelCase__						:       Dict										=						logging.get_logger(__name__)




def 	_a       (				__lowerCAmelCase		:      Dict     ):

		"""simple docstring"""

		if isinstance(__lowerCAmelCase   ,							(list, tuple)     ) and isinstance(videos[0]   ,							(list, tuple)     ) and is_valid_image(videos[0][0]     ):
				return videos

		elif isinstance(__lowerCAmelCase   ,							(list, tuple)     ) and is_valid_image(videos[0]     ):
				return [videos]

		elif is_valid_image(__lowerCAmelCase     ):
				return [[videos]]

		raise ValueError(F"""Could not make batched video from {videos}"""     )





class     a			(				SCREAMING_SNAKE_CASE       ):






						"""simple docstring"""




						__UpperCAmelCase			     =    ["""pixel_values"""]







						def __init__(							self					:      Dict			,			snake_case_					:      bool = True			,			snake_case_					:      Dict[str, int] = None			,			snake_case_					:      PILImageResampling = PILImageResampling.BILINEAR			,			snake_case_					:      bool = True			,			snake_case_					:      Dict[str, int] = None			,			snake_case_					:      bool = True			,			snake_case_					:      Union[int, float] = 1 / 2_5_5			,			snake_case_					:      bool = True			,			snake_case_					:      Optional[Union[float, List[float]]] = None			,			snake_case_					:      Optional[Union[float, List[float]]] = None			,			**snake_case_					:      Tuple			,			):



								'''simple docstring'''



								super().__init__(**snake_case_  )
								snake_case__						:       List[str]       						=  size if size is not None else {'''shortest_edge''': 2_2_4}
								snake_case__						:       List[str]       						=  get_size_dict(snake_case_			,			default_to_square=snake_case_  )
								snake_case__						:       List[str]       						=  crop_size if crop_size is not None else {'''height''': 2_2_4, '''width''': 2_2_4}
								snake_case__						:       int       						=  get_size_dict(snake_case_			,			param_name='''crop_size'''  )

								snake_case__						:       Optional[int]       						=  do_resize
								snake_case__						:       Dict       						=  size
								snake_case__						:       str       						=  do_center_crop
								snake_case__						:       str       						=  crop_size
								snake_case__						:       str       						=  resample
								snake_case__						:       Tuple       						=  do_rescale
								snake_case__						:       Optional[int]       						=  rescale_factor
								snake_case__						:       Optional[int]       						=  do_normalize
								snake_case__						:       Optional[Any]       						=  image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
								snake_case__						:       Union[str, Any]       						=  image_std if image_std is not None else IMAGENET_STANDARD_STD







						def       __magic_name__							(							self					:      Dict			,			snake_case_					:      np.ndarray			,			snake_case_					:      Dict[str, int]			,			snake_case_					:      PILImageResampling = PILImageResampling.BILINEAR			,			snake_case_					:      Optional[Union[str, ChannelDimension]] = None			,			**snake_case_					:      List[str]			,			):



								'''simple docstring'''



								snake_case__						:       Optional[int]       						=  get_size_dict(snake_case_			,			default_to_square=snake_case_  )
								if "shortest_edge" in size:
										snake_case__						:       Tuple       						=  get_resize_output_image_size(snake_case_			,			size['''shortest_edge''']			,			default_to_square=snake_case_  )
								elif "height" in size and "width" in size:
										snake_case__						:       int       						=  (size['''height'''], size['''width'''])
								else:
										raise ValueError(F"""Size must have 'height' and 'width' or 'shortest_edge' as keys. Got {size.keys()}"""  )
								return resize(snake_case_			,			size=snake_case_			,			resample=snake_case_			,			data_format=snake_case_			,			**snake_case_  )







						def       __magic_name__							(							self					:      Dict			,			snake_case_					:      np.ndarray			,			snake_case_					:      Dict[str, int]			,			snake_case_					:      Optional[Union[str, ChannelDimension]] = None			,			**snake_case_					:      Dict			,			):



								'''simple docstring'''



								snake_case__						:       List[str]       						=  get_size_dict(snake_case_  )
								if "height" not in size or "width" not in size:
										raise ValueError(F"""Size must have 'height' and 'width' as keys. Got {size.keys()}"""  )
								return center_crop(snake_case_			,			size=(size['''height'''], size['''width'''])			,			data_format=snake_case_			,			**snake_case_  )







						def       __magic_name__							(							self					:      str			,			snake_case_					:      np.ndarray			,			snake_case_					:      Union[int, float]			,			snake_case_					:      Optional[Union[str, ChannelDimension]] = None			,			**snake_case_					:      Optional[int]			,			):



								'''simple docstring'''



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







						def       __magic_name__							(							self					:      Optional[int]			,			snake_case_					:      np.ndarray			,			snake_case_					:      Union[float, List[float]]			,			snake_case_					:      Union[float, List[float]]			,			snake_case_					:      Optional[Union[str, ChannelDimension]] = None			,			**snake_case_					:      Any			,			):



								'''simple docstring'''



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







						def       __magic_name__							(							self					:      List[Any]			,			snake_case_					:      ImageInput			,			snake_case_					:      bool = None			,			snake_case_					:      Dict[str, int] = None			,			snake_case_					:      PILImageResampling = None			,			snake_case_					:      bool = None			,			snake_case_					:      Dict[str, int] = None			,			snake_case_					:      bool = None			,			snake_case_					:      float = None			,			snake_case_					:      bool = None			,			snake_case_					:      Optional[Union[float, List[float]]] = None			,			snake_case_					:      Optional[Union[float, List[float]]] = None			,			snake_case_					:      Optional[ChannelDimension] = ChannelDimension.FIRST			,			):



								'''simple docstring'''



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

								if do_center_crop and crop_size is None:
										raise ValueError('''Crop size must be specified if do_center_crop 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 std must be specified if do_normalize is True.'''  )

								# All transformations expect numpy arrays.
								snake_case__						:       str       						=  to_numpy_array(snake_case_  )

								if do_resize:
										snake_case__						:       str       						=  self.resize(image=snake_case_			,			size=snake_case_			,			resample=snake_case_  )

								if do_center_crop:
										snake_case__						:       Tuple       						=  self.center_crop(snake_case_			,			size=snake_case_  )

								if do_rescale:
										snake_case__						:       Optional[int]       						=  self.rescale(image=snake_case_			,			scale=snake_case_  )

								if do_normalize:
										snake_case__						:       Optional[Any]       						=  self.normalize(image=snake_case_			,			mean=snake_case_			,			std=snake_case_  )

								snake_case__						:       Union[str, Any]       						=  to_channel_dimension_format(snake_case_			,			snake_case_  )
								return image







						def       __magic_name__							(							self					:      str			,			snake_case_					:      ImageInput			,			snake_case_					:      bool = None			,			snake_case_					:      Dict[str, int] = None			,			snake_case_					:      PILImageResampling = None			,			snake_case_					:      bool = None			,			snake_case_					:      Dict[str, int] = None			,			snake_case_					:      bool = None			,			snake_case_					:      float = None			,			snake_case_					:      bool = None			,			snake_case_					:      Optional[Union[float, List[float]]] = None			,			snake_case_					:      Optional[Union[float, List[float]]] = None			,			snake_case_					:      Optional[Union[str, TensorType]] = None			,			snake_case_					:      ChannelDimension = ChannelDimension.FIRST			,			**snake_case_					:      List[Any]			,			):



								'''simple docstring'''



								snake_case__						:       Tuple       						=  do_resize if do_resize is not None else self.do_resize
								snake_case__						:       Union[str, Any]       						=  resample if resample is not None else self.resample
								snake_case__						:       str       						=  do_center_crop if do_center_crop is not None else self.do_center_crop
								snake_case__						:       Union[str, Any]       						=  do_rescale if do_rescale is not None else self.do_rescale
								snake_case__						:       Any       						=  rescale_factor if rescale_factor is not None else self.rescale_factor
								snake_case__						:       Any       						=  do_normalize if do_normalize is not None else self.do_normalize
								snake_case__						:       List[Any]       						=  image_mean if image_mean is not None else self.image_mean
								snake_case__						:       Any       						=  image_std if image_std is not None else self.image_std

								snake_case__						:       str       						=  size if size is not None else self.size
								snake_case__						:       List[Any]       						=  get_size_dict(snake_case_			,			default_to_square=snake_case_  )
								snake_case__						:       List[Any]       						=  crop_size if crop_size is not None else self.crop_size
								snake_case__						:       str       						=  get_size_dict(snake_case_			,			param_name='''crop_size'''  )

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

								snake_case__						:       Optional[Any]       						=  make_batched(snake_case_  )

								snake_case__						:       Dict       						=  [
								    [
								        self._preprocess_image(
								            image=snake_case_			,			do_resize=snake_case_			,			size=snake_case_			,			resample=snake_case_			,			do_center_crop=snake_case_			,			crop_size=snake_case_			,			do_rescale=snake_case_			,			rescale_factor=snake_case_			,			do_normalize=snake_case_			,			image_mean=snake_case_			,			image_std=snake_case_			,			data_format=snake_case_			,			)
								        for img in video
								    ]
								    for video in videos
								]

								snake_case__						:       Any       						=  {'''pixel_values''': videos}
								return BatchFeature(data=snake_case_			,			tensor_type=snake_case_  )






'''simple docstring'''


def 	_a       (				__lowerCAmelCase		:      int     ):

		"""simple docstring"""

		if p < 2:
				raise ValueError('''p should not be less than 2!'''     )
		elif p == 2:
				return True

		snake_case__						:       Any       						=  4
		snake_case__						:       int       						=  (1 << p) - 1
		for _ in range(p - 2     ):
				snake_case__						:       Tuple       						=  ((s * s) - 2) % m
		return s == 0


if __name__ == "__main__":
					print(lucas_lehmer_test(7))
					print(lucas_lehmer_test(11))



