





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_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
							import PIL


__UpperCAmelCase         =   logging.get_logger(__name__)




class       UpperCamelCase__			(			lowerCamelCase__	):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__						=					['pixel_values']


					def __init__(		self							:	Dict     ,		lowerCamelCase_							:	Union[str, Any] = True     ,		lowerCamelCase_							:	List[str] = None     ,		lowerCamelCase_							:	Any = PIL.Image.NEAREST     ,		lowerCamelCase_							:	Optional[int] = False     ,		lowerCamelCase_							:	List[str] = None     ,		lowerCamelCase_							:	Any = 1 / 2_55     ,		lowerCamelCase_							:	str = False     ,		lowerCamelCase_							:	Optional[int] = True     ,		lowerCamelCase_							:	Dict = True     ,		lowerCamelCase_							:	int = None     ,		lowerCamelCase_							:	List[str] = None     ,		lowerCamelCase_							:	int = True     ,		**lowerCamelCase_							:	List[Any]     ,		):

							'''simple docstring'''



							super().__init__(**lowercase_		)
							SCREAMING_SNAKE_CASE				:							int						=	size if size is not None else {"""height""": 3_46, """width""": 3_46}
							SCREAMING_SNAKE_CASE				:							Tuple						=	get_size_dict(lowercase_		)
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	crop_size if crop_size is not None else {"""height""": 2_89, """width""": 2_89}
							SCREAMING_SNAKE_CASE				:							Dict						=	get_size_dict(lowercase_     ,		param_name="""crop_size"""		)

							SCREAMING_SNAKE_CASE				:							List[str]						=	do_resize
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	size
							SCREAMING_SNAKE_CASE				:							str						=	resample
							SCREAMING_SNAKE_CASE				:							int						=	do_center_crop
							SCREAMING_SNAKE_CASE				:							Dict						=	crop_size
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	do_rescale
							SCREAMING_SNAKE_CASE				:							Tuple						=	rescale_factor
							SCREAMING_SNAKE_CASE				:							int						=	rescale_offset
							SCREAMING_SNAKE_CASE				:							List[str]						=	do_normalize
							SCREAMING_SNAKE_CASE				:							str						=	image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
							SCREAMING_SNAKE_CASE				:							List[Any]						=	image_std if image_std is not None else IMAGENET_STANDARD_STD
							SCREAMING_SNAKE_CASE				:							Tuple						=	include_top


					def lowerCamelCase_	(		self							:	Union[str, Any]     ,		lowerCamelCase_							:	int     ,		lowerCamelCase_							:	Tuple     ,		lowerCamelCase_							:	Dict = PIL.Image.NEAREST     ,		lowerCamelCase_							:	List[str] = None     ,		**lowerCamelCase_							:	str     ,		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Any						=	get_size_dict(lowercase_		)
							if "height" not in size or "width" not in size:
									raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}'''		)
							return resize(
							    lowercase_     ,		size=(size["""height"""], size["""width"""])     ,		resample=lowercase_     ,		data_format=lowercase_     ,		**lowercase_		)


					def lowerCamelCase_	(		self							:	Dict     ,		lowerCamelCase_							:	Tuple     ,		lowerCamelCase_							:	List[str]     ,		lowerCamelCase_							:	int = None     ,		**lowerCamelCase_							:	Optional[Any]     ,		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	get_size_dict(lowercase_		)
							if "height" not in size or "width" not in size:
									raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}'''		)
							return center_crop(lowercase_     ,		size=(size["""height"""], size["""width"""])     ,		data_format=lowercase_     ,		**lowercase_		)


					def lowerCamelCase_	(		self							:	Optional[Any]     ,		lowerCamelCase_							:	int     ,		lowerCamelCase_							:	Union[str, Any]     ,		lowerCamelCase_							:	Any = True     ,		lowerCamelCase_							:	str = None     ,		**lowerCamelCase_							:	Optional[Any]     ,		):

							'''simple docstring'''



							if offset:
									SCREAMING_SNAKE_CASE				:							List[str]						=	(image - 127.5) * scale
									if data_format is not None:
											SCREAMING_SNAKE_CASE				:							int						=	to_channel_dimension_format(lowercase_     ,		lowercase_		)
									SCREAMING_SNAKE_CASE				:							int						=	rescaled_image.astype(np.floataa		)
							else:
									SCREAMING_SNAKE_CASE				:							List[str]						=	rescale(lowercase_     ,		scale=lowercase_     ,		data_format=lowercase_     ,		**lowercase_		)
							return rescaled_image


					def lowerCamelCase_	(		self							:	Tuple     ,		lowerCamelCase_							:	List[Any]     ,		lowerCamelCase_							:	str     ,		lowerCamelCase_							:	Optional[int]     ,		lowerCamelCase_							:	Optional[Any] = None     ,		**lowerCamelCase_							:	Tuple     ,		):

							'''simple docstring'''



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



					def lowerCamelCase_	(		self							:	List[Any]     ,		lowerCamelCase_							:	Optional[Any]     ,		lowerCamelCase_							:	List[str] = None     ,		lowerCamelCase_							:	Union[str, Any] = None     ,		lowerCamelCase_							:	Optional[int]=None     ,		lowerCamelCase_							:	Optional[int] = None     ,		lowerCamelCase_							:	Optional[int] = None     ,		lowerCamelCase_							:	str = None     ,		lowerCamelCase_							:	List[Any] = None     ,		lowerCamelCase_							:	Tuple = None     ,		lowerCamelCase_							:	Union[str, Any] = None     ,		lowerCamelCase_							:	Union[str, Any] = None     ,		lowerCamelCase_							:	Any = None     ,		lowerCamelCase_							:	Union[str, Any] = None     ,		lowerCamelCase_							:	str = None     ,		lowerCamelCase_							:	Union[str, Any] = ChannelDimension.FIRST     ,		**lowerCamelCase_							:	Dict     ,		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Optional[int]						=	do_resize if do_resize is not None else self.do_resize
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	resample if resample is not None else self.resample
							SCREAMING_SNAKE_CASE				:							Any						=	do_center_crop if do_center_crop is not None else self.do_center_crop
							SCREAMING_SNAKE_CASE				:							List[Any]						=	do_rescale if do_rescale is not None else self.do_rescale
							SCREAMING_SNAKE_CASE				:							List[str]						=	rescale_factor if rescale_factor is not None else self.rescale_factor
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	rescale_offset if rescale_offset is not None else self.rescale_offset
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	do_normalize if do_normalize is not None else self.do_normalize
							SCREAMING_SNAKE_CASE				:							List[Any]						=	image_mean if image_mean is not None else self.image_mean
							SCREAMING_SNAKE_CASE				:							int						=	image_std if image_std is not None else self.image_std
							SCREAMING_SNAKE_CASE				:							Any						=	include_top if include_top is not None else self.include_top

							SCREAMING_SNAKE_CASE				:							Any						=	size if size is not None else self.size
							SCREAMING_SNAKE_CASE				:							int						=	get_size_dict(lowercase_		)
							SCREAMING_SNAKE_CASE				:							List[str]						=	crop_size if crop_size is not None else self.crop_size
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	get_size_dict(lowercase_     ,		param_name="""crop_size"""		)

							SCREAMING_SNAKE_CASE				:							Tuple						=	make_list_of_images(lowercase_		)

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

							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.
							SCREAMING_SNAKE_CASE				:							List[Any]						=	[to_numpy_array(lowercase_		) for image in images]

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

							if do_center_crop:
									SCREAMING_SNAKE_CASE				:							List[str]						=	[self.center_crop(image=lowercase_     ,		size=lowercase_		) for image in images]

							if do_rescale:
									SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	[self.rescale(image=lowercase_     ,		scale=lowercase_     ,		offset=lowercase_		) for image in images]

							if do_normalize:
									SCREAMING_SNAKE_CASE				:							int						=	[self.normalize(image=lowercase_     ,		mean=lowercase_     ,		std=lowercase_		) for image in images]

							if include_top:
									SCREAMING_SNAKE_CASE				:							List[str]						=	[self.normalize(image=lowercase_     ,		mean=[0, 0, 0]     ,		std=lowercase_		) for image in images]

							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	[to_channel_dimension_format(lowercase_     ,		lowercase_		) for image in images]

							SCREAMING_SNAKE_CASE				:							Optional[int]						=	{"""pixel_values""": images}
							return BatchFeature(data=lowercase_     ,		tensor_type=lowercase_		)










'''simple docstring'''




from __future__ import annotations

from collections import Counter



def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							int						=	[True] * n
		SCREAMING_SNAKE_CASE				:							Optional[Any]						=	False
		SCREAMING_SNAKE_CASE				:							Optional[Any]						=	False
		SCREAMING_SNAKE_CASE				:							Optional[int]						=	True

		for i in range(3	,	int(n**0.5 + 1					)	,	2					):
				SCREAMING_SNAKE_CASE				:							List[Any]						=	i * 2
				while index < n:
						SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	False
						SCREAMING_SNAKE_CASE				:							Optional[Any]						=	index + i

		SCREAMING_SNAKE_CASE				:							Dict						=	[2]

		for i in range(3	,	lowerCamelCase_	,	2					):
				if is_prime[i]:
						primes.append(lowerCamelCase_					)

		return primes



def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							List[str]						=	str(lowerCamelCase_					)
		SCREAMING_SNAKE_CASE				:							List[str]						=	[]
		SCREAMING_SNAKE_CASE				:							Optional[int]						=	["""0""", """1""", """2""", """3""", """4""", """5""", """6""", """7""", """8""", """9"""]

		for duplicate in Counter(lowerCamelCase_					) - Counter(set(lowerCamelCase_					)					):
				SCREAMING_SNAKE_CASE				:							Tuple						=	[int(number_str.replace(lowerCamelCase_	,	lowerCamelCase_					)					) for digit in digits]
				replacements.append(lowerCamelCase_					)

		return replacements



def 						__A						(       lowerCamelCase_ = 8					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							Tuple						=	set()

		# Filter primes with less than 3 replaceable digits
		SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	{
		    x for x in set(prime_sieve(1_00_00_00					)					) if len(str(lowerCamelCase_					)					) - len(set(str(lowerCamelCase_					)					)					) >= 3
		}

		for prime in primes:
				if prime in numbers_checked:
						continue

				SCREAMING_SNAKE_CASE				:							int						=	digit_replacements(lowerCamelCase_					)

				for family in replacements:
						numbers_checked.update(lowerCamelCase_					)
						SCREAMING_SNAKE_CASE				:							Dict						=	primes.intersection(lowerCamelCase_					)

						if len(lowerCamelCase_					) != family_length:
								continue

						return min(lowerCamelCase_					)

		return -1


if __name__ == "__main__":
							print(solution())



