






"""simple docstring"""
import math

def 				snake_case      (   A__						):
			UpperCAmelCase_     : Optional[int]			     =					[]
			UpperCAmelCase_     : Optional[int]			     =					2
			UpperCAmelCase_     : Tuple			     =					int(math.sqrt(A__						)						)  # Size of every segment
			UpperCAmelCase_     : Optional[int]			     =					[True] * (end + 1)
			UpperCAmelCase_     : Union[str, Any]			     =					[]

			while start <= end:
						if temp[start] is True:
									in_prime.append(A__						)
									for i in range(start * start	,end + 1	,A__						):
												UpperCAmelCase_     : str			     =					False
						start += 1
			prime += in_prime

			UpperCAmelCase_     : Union[str, Any]			     =					end + 1
			UpperCAmelCase_     : str			     =					min(2 * end	,A__						)

			while low <= n:
						UpperCAmelCase_     : Optional[int]			     =					[True] * (high - low + 1)
						for each in in_prime:
									UpperCAmelCase_     : Dict			     =					math.floor(low / each						) * each
									if t < low:
												t += each

									for j in range(A__	,high + 1	,A__						):
												UpperCAmelCase_     : Dict			     =					False

						for j in range(len(A__						)						):
									if temp[j] is True:
												prime.append(j + low						)

						UpperCAmelCase_     : Optional[Any]			     =					high + 1
						UpperCAmelCase_     : str			     =					min(high + end	,A__						)

			return prime




print(sieve(10**6))











"""simple docstring"""
from __future__ import annotations

import inspect
import unittest
from typing import List, Tuple

from transformers import RegNetConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
			import tensorflow as tf

			from transformers import TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST, TFRegNetForImageClassification, TFRegNetModel


if is_vision_available():
			from PIL import Image

			from transformers import AutoImageProcessor







class 			UpperCamelCase_       :





	def __init__(      self					: Optional[Any]	,	lowerCAmelCase_					: Optional[Any]	,	lowerCAmelCase_					: Optional[int]=3	,	lowerCAmelCase_					: Optional[int]=32	,	lowerCAmelCase_					: List[Any]=3	,	lowerCAmelCase_					: List[Any]=10	,	lowerCAmelCase_					: Any=[10, 20, 30, 40]	,	lowerCAmelCase_					: Any=[1, 1, 2, 1]	,	lowerCAmelCase_					: Union[str, Any]=True	,	lowerCAmelCase_					: Union[str, Any]=True	,	lowerCAmelCase_					: int="relu"	,	lowerCAmelCase_					: Tuple=3	,	lowerCAmelCase_					: Optional[int]=None	,	)						->			str:
				UpperCAmelCase_     : Tuple			     =					parent
				UpperCAmelCase_     : int			     =					batch_size
				UpperCAmelCase_     : str			     =					image_size
				UpperCAmelCase_     : List[Any]			     =					num_channels
				UpperCAmelCase_     : Tuple			     =					embeddings_size
				UpperCAmelCase_     : Union[str, Any]			     =					hidden_sizes
				UpperCAmelCase_     : int			     =					depths
				UpperCAmelCase_     : Optional[Any]			     =					is_training
				UpperCAmelCase_     : Dict			     =					use_labels
				UpperCAmelCase_     : str			     =					hidden_act
				UpperCAmelCase_     : str			     =					num_labels
				UpperCAmelCase_     : str			     =					scope
				UpperCAmelCase_     : str			     =					len(lowerCAmelCase_						)





	def      _SCREAMING_SNAKE_CASE      (      self					: Tuple						)						->			Dict:
				UpperCAmelCase_     : Any			     =					floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

				UpperCAmelCase_     : Union[str, Any]			     =					None
				if self.use_labels:
							UpperCAmelCase_     : List[str]			     =					ids_tensor([self.batch_size]	,	self.num_labels						)

				UpperCAmelCase_     : Optional[Any]			     =					self.get_config()
				return config, pixel_values, labels





	def      _SCREAMING_SNAKE_CASE      (      self					: List[str]						)						->			Union[str, Any]:
				return RegNetConfig(
				    num_channels=self.num_channels	,	embeddings_size=self.embeddings_size	,	hidden_sizes=self.hidden_sizes	,	depths=self.depths	,	hidden_act=self.hidden_act	,	num_labels=self.num_labels	,	)





	def      _SCREAMING_SNAKE_CASE      (      self					: Optional[int]	,	lowerCAmelCase_					: Union[str, Any]	,	lowerCAmelCase_					: str	,	lowerCAmelCase_					: Dict						)						->			str:
				UpperCAmelCase_     : List[Any]			     =					TFRegNetModel(config=lowerCAmelCase_						)
				UpperCAmelCase_     : List[Any]			     =					model(lowerCAmelCase_	,	training=lowerCAmelCase_						)
				# expected last hidden states: B, C, H // 32, W // 32
				self.parent.assertEqual(
				    result.last_hidden_state.shape	,	(self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)	,	)





	def      _SCREAMING_SNAKE_CASE      (      self					: Optional[int]	,	lowerCAmelCase_					: Tuple	,	lowerCAmelCase_					: Tuple	,	lowerCAmelCase_					: List[Any]						)						->			Optional[Any]:
				UpperCAmelCase_     : Union[str, Any]			     =					self.num_labels
				UpperCAmelCase_     : List[Any]			     =					TFRegNetForImageClassification(lowerCAmelCase_						)
				UpperCAmelCase_     : Optional[int]			     =					model(lowerCAmelCase_	,	labels=lowerCAmelCase_	,	training=lowerCAmelCase_						)
				self.parent.assertEqual(result.logits.shape	,	(self.batch_size, self.num_labels)						)





	def      _SCREAMING_SNAKE_CASE      (      self					: List[Any]						)						->			Dict:
				UpperCAmelCase_     : Any			     =					self.prepare_config_and_inputs()
				UpperCAmelCase_     ,	UpperCAmelCase_     ,	UpperCAmelCase_     : Dict			     =					config_and_inputs
				UpperCAmelCase_     : List[str]			     =					{"pixel_values": pixel_values}
				return config, inputs_dict







@require_tf
class 			UpperCamelCase_       (__A				,						__A				,						unittest.TestCase     ):
	__magic_name__	      =				(TFRegNetModel, TFRegNetForImageClassification) if is_tf_available() else ()
	__magic_name__	      =				(
	    {'''feature-extraction''': TFRegNetModel, '''image-classification''': TFRegNetForImageClassification}
	    if is_tf_available()
	    else {}
	)

	__magic_name__	      =				False
	__magic_name__	      =				False
	__magic_name__	      =				False
	__magic_name__	      =				False
	__magic_name__	      =				False





	def      _SCREAMING_SNAKE_CASE      (      self					: Optional[int]						)						->			Union[str, Any]:
				UpperCAmelCase_     : Optional[int]			     =					TFRegNetModelTester(self						)
				UpperCAmelCase_     : Optional[Any]			     =					ConfigTester(self	,	config_class=lowerCAmelCase_	,	has_text_modality=lowerCAmelCase_						)





	def      _SCREAMING_SNAKE_CASE      (      self					: List[str]						)						->			Optional[int]:
				return





	@unittest.skip(reason="RegNet does not use inputs_embeds"						)
	def      _SCREAMING_SNAKE_CASE      (      self					: List[str]						)						->			Union[str, Any]:
				pass





	@unittest.skipIf(
	    not is_tf_available() or len(tf.config.list_physical_devices("GPU"						)						) == 0	,	reason="TF does not support backprop for grouped convolutions on CPU."	,	)
	@slow
	def      _SCREAMING_SNAKE_CASE      (      self					: List[str]						)						->			Dict:
				super().test_keras_fit()





	@unittest.skip(reason="RegNet does not support input and output embeddings"						)
	def      _SCREAMING_SNAKE_CASE      (      self					: List[str]						)						->			Any:
				pass





	def      _SCREAMING_SNAKE_CASE      (      self					: int						)						->			List[str]:
				UpperCAmelCase_     ,	UpperCAmelCase_     : Tuple			     =					self.model_tester.prepare_config_and_inputs_for_common()

				for model_class in self.all_model_classes:
							UpperCAmelCase_     : Dict			     =					model_class(lowerCAmelCase_						)
							UpperCAmelCase_     : Tuple			     =					inspect.signature(model.call						)
							# signature.parameters is an OrderedDict => so arg_names order is deterministic
							UpperCAmelCase_     : List[Any]			     =					[*signature.parameters.keys()]

							UpperCAmelCase_     : int			     =					["pixel_values"]
							self.assertListEqual(arg_names[:1]	,	lowerCAmelCase_						)





	def      _SCREAMING_SNAKE_CASE      (      self					: Union[str, Any]						)						->			Union[str, Any]:
				UpperCAmelCase_     : List[Any]			     =					self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_model(*lowerCAmelCase_						)





	def      _SCREAMING_SNAKE_CASE      (      self					: Optional[Any]						)						->			Optional[int]:
				def check_hidden_states_output(lowerCAmelCase_					: Optional[int]	,	lowerCAmelCase_					: Dict	,	lowerCAmelCase_					: int						):
							UpperCAmelCase_     : str			     =					model_class(lowerCAmelCase_						)
							UpperCAmelCase_     : Any			     =					model(**self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_						)	,	training=lowerCAmelCase_						)

							UpperCAmelCase_     : str			     =					outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

							UpperCAmelCase_     : Optional[Any]			     =					self.model_tester.num_stages
							self.assertEqual(len(lowerCAmelCase_						)	,	expected_num_stages + 1						)

							# RegNet's feature maps are of shape (batch_size, num_channels, height, width)
							self.assertListEqual(
							    list(hidden_states[0].shape[-2:]						)	,	[self.model_tester.image_size // 2, self.model_tester.image_size // 2]	,	)

				UpperCAmelCase_     ,	UpperCAmelCase_     : List[str]			     =					self.model_tester.prepare_config_and_inputs_for_common()
				UpperCAmelCase_     : Tuple			     =					["basic", "bottleneck"]
				for model_class in self.all_model_classes:
							for layer_type in layers_type:
										UpperCAmelCase_     : List[Any]			     =					layer_type
										UpperCAmelCase_     : int			     =					True
										check_hidden_states_output(lowerCAmelCase_	,	lowerCAmelCase_	,	lowerCAmelCase_						)

										# check that output_hidden_states also work using config
										del inputs_dict["output_hidden_states"]
										UpperCAmelCase_     : Optional[int]			     =					True

										check_hidden_states_output(lowerCAmelCase_	,	lowerCAmelCase_	,	lowerCAmelCase_						)





	def      _SCREAMING_SNAKE_CASE      (      self					: Union[str, Any]						)						->			Any:
				UpperCAmelCase_     ,	UpperCAmelCase_     : Any			     =					self.model_tester.prepare_config_and_inputs_for_common()

				def check_equivalence(lowerCAmelCase_					: Optional[Any]	,	lowerCAmelCase_					: Tuple	,	lowerCAmelCase_					: Optional[Any]	,	lowerCAmelCase_					: List[str]={}						):
							UpperCAmelCase_     : Tuple			     =					model(lowerCAmelCase_	,	return_dict=lowerCAmelCase_	,	**lowerCAmelCase_						)
							UpperCAmelCase_     : Optional[Any]			     =					model(lowerCAmelCase_	,	return_dict=lowerCAmelCase_	,	**lowerCAmelCase_						).to_tuple()

							def recursive_check(lowerCAmelCase_					: List[Any]	,	lowerCAmelCase_					: Any						):
										if isinstance(lowerCAmelCase_	,	(List, Tuple)						):
													for tuple_iterable_value, dict_iterable_value in zip(lowerCAmelCase_	,	lowerCAmelCase_						):
																recursive_check(lowerCAmelCase_	,	lowerCAmelCase_						)
										elif tuple_object is None:
													return
										else:
													self.assertTrue(
													    all(tf.equal(lowerCAmelCase_	,	lowerCAmelCase_						)						)	,	msg=(
													        "Tuple and dict output are not equal. Difference:"
													        f""" {tf.math.reduce_max(tf.abs(tuple_object - dict_object						)						)}"""
													    )	,	)

										recursive_check(lowerCAmelCase_	,	lowerCAmelCase_						)

				for model_class in self.all_model_classes:
							UpperCAmelCase_     : Union[str, Any]			     =					model_class(lowerCAmelCase_						)

							UpperCAmelCase_     : List[Any]			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_						)
							UpperCAmelCase_     : str			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_						)
							check_equivalence(lowerCAmelCase_	,	lowerCAmelCase_	,	lowerCAmelCase_						)

							UpperCAmelCase_     : Any			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_	,	return_labels=lowerCAmelCase_						)
							UpperCAmelCase_     : List[Any]			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_	,	return_labels=lowerCAmelCase_						)
							check_equivalence(lowerCAmelCase_	,	lowerCAmelCase_	,	lowerCAmelCase_						)

							UpperCAmelCase_     : Union[str, Any]			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_						)
							UpperCAmelCase_     : str			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_						)
							check_equivalence(lowerCAmelCase_	,	lowerCAmelCase_	,	lowerCAmelCase_	,	{"output_hidden_states": True}						)

							UpperCAmelCase_     : List[str]			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_	,	return_labels=lowerCAmelCase_						)
							UpperCAmelCase_     : Tuple			     =					self._prepare_for_class(lowerCAmelCase_	,	lowerCAmelCase_	,	return_labels=lowerCAmelCase_						)
							check_equivalence(lowerCAmelCase_	,	lowerCAmelCase_	,	lowerCAmelCase_	,	{"output_hidden_states": True}						)





	def      _SCREAMING_SNAKE_CASE      (      self					: Union[str, Any]						)						->			str:
				UpperCAmelCase_     : List[str]			     =					self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase_						)





	@slow
	def      _SCREAMING_SNAKE_CASE      (      self					: str						)						->			Union[str, Any]:
				for model_name in TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							UpperCAmelCase_     : Any			     =					TFRegNetModel.from_pretrained(lowerCAmelCase_						)
							self.assertIsNotNone(lowerCAmelCase_						)





def 				snake_case      (   ):
			UpperCAmelCase_     : Dict			     =					Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						)
			return image







@require_tf
@require_vision
class 			UpperCamelCase_       (unittest.TestCase     ):





	@cached_property
	def      _SCREAMING_SNAKE_CASE      (      self					: List[Any]						)						->			List[Any]:
				return (
				    AutoImageProcessor.from_pretrained(TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]						)
				    if is_vision_available()
				    else None
				)





	@slow
	def      _SCREAMING_SNAKE_CASE      (      self					: Tuple						)						->			Dict:
				UpperCAmelCase_     : Any			     =					TFRegNetForImageClassification.from_pretrained(TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]						)

				UpperCAmelCase_     : Union[str, Any]			     =					self.default_image_processor
				UpperCAmelCase_     : int			     =					prepare_img()
				UpperCAmelCase_     : List[Any]			     =					image_processor(images=lowerCAmelCase_	,	return_tensors="tf"						)

				# forward pass
				UpperCAmelCase_     : Tuple			     =					model(**lowerCAmelCase_	,	training=lowerCAmelCase_						)

				# verify the logits
				UpperCAmelCase_     : List[str]			     =					tf.TensorShape((1, 1_000)						)
				self.assertEqual(outputs.logits.shape	,	lowerCAmelCase_						)

				UpperCAmelCase_     : Optional[Any]			     =					tf.constant([-0.4_1_8_0, -1.5_0_5_1, -3.4_8_3_6]						)

				tf.debugging.assert_near(outputs.logits[0, :3]	,	lowerCAmelCase_	,	atol=1e-4						)



