



import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    MODEL_FOR_PRETRAINING_MAPPING,
		    AlbertForMaskedLM,
		    AlbertForMultipleChoice,
		    AlbertForPreTraining,
		    AlbertForQuestionAnswering,
		    AlbertForSequenceClassification,
		    AlbertForTokenClassification,
		    AlbertModel,
		)
		from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST

class        snake_case__    :







						"""simple docstring"""




						def __init__(       self ,       __lowercase ,       __lowercase=1_3 ,       __lowercase=7 ,       __lowercase=True ,       __lowercase=True ,       __lowercase=True ,       __lowercase=True ,       __lowercase=9_9 ,       __lowercase=1_6 ,       __lowercase=3_6 ,       __lowercase=6 ,       __lowercase=6 ,       __lowercase=6 ,       __lowercase=3_7 ,       __lowercase="gelu" ,       __lowercase=0.1 ,       __lowercase=0.1 ,       __lowercase=5_1_2 ,       __lowercase=1_6 ,       __lowercase=2 ,       __lowercase=0.0_2 ,       __lowercase=3 ,       __lowercase=4 ,       __lowercase=None ,       ) ->				List[Any]:
									"""simple docstring"""




									a__       :						Any							=  parent
									a__       :						str							=  batch_size
									a__       :						List[str]							=  seq_length
									a__       :						str							=  is_training
									a__       :						Optional[int]							=  use_input_mask
									a__       :						Optional[Any]							=  use_token_type_ids
									a__       :						Optional[Any]							=  use_labels
									a__       :						str							=  vocab_size
									a__       :						int							=  embedding_size
									a__       :						Any							=  hidden_size
									a__       :						List[Any]							=  num_hidden_layers
									a__       :						Tuple							=  num_hidden_groups
									a__       :						List[str]							=  num_attention_heads
									a__       :						List[str]							=  intermediate_size
									a__       :						Dict							=  hidden_act
									a__       :						Optional[int]							=  hidden_dropout_prob
									a__       :						int							=  attention_probs_dropout_prob
									a__       :						Any							=  max_position_embeddings
									a__       :						List[str]							=  type_vocab_size
									a__       :						List[Any]							=  type_sequence_label_size
									a__       :						List[Any]							=  initializer_range
									a__       :						Tuple							=  num_labels
									a__       :						Tuple							=  num_choices
									a__       :						Dict							=  scope

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				int:
									"""simple docstring"""




									a__       :						Optional[Any]							=  ids_tensor([self.batch_size, self.seq_length] ,       self.vocab_size  )

									a__       :						List[str]							=  None
									if self.use_input_mask:
												a__       :						List[str]							=  random_attention_mask([self.batch_size, self.seq_length]  )

									a__       :						List[Any]							=  None
									if self.use_token_type_ids:
												a__       :						Tuple							=  ids_tensor([self.batch_size, self.seq_length] ,       self.type_vocab_size  )

									a__       :						List[Any]							=  None
									a__       :						Optional[Any]							=  None
									a__       :						Optional[Any]							=  None
									if self.use_labels:
												a__       :						Optional[int]							=  ids_tensor([self.batch_size] ,       self.type_sequence_label_size  )
												a__       :						Union[str, Any]							=  ids_tensor([self.batch_size, self.seq_length] ,       self.num_labels  )
												a__       :						str							=  ids_tensor([self.batch_size] ,       self.num_choices  )

									a__       :						List[Any]							=  self.get_config()

									return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				List[str]:
									"""simple docstring"""




									return AlbertConfig(
									    vocab_size=self.vocab_size ,       hidden_size=self.hidden_size ,       num_hidden_layers=self.num_hidden_layers ,       num_attention_heads=self.num_attention_heads ,       intermediate_size=self.intermediate_size ,       hidden_act=self.hidden_act ,       hidden_dropout_prob=self.hidden_dropout_prob ,       attention_probs_dropout_prob=self.attention_probs_dropout_prob ,       max_position_embeddings=self.max_position_embeddings ,       type_vocab_size=self.type_vocab_size ,       initializer_range=self.initializer_range ,       num_hidden_groups=self.num_hidden_groups ,       )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				Union[str, Any]:
									"""simple docstring"""




									a__       :						List[Any]							=  AlbertModel(config=_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						Any							=  model(_lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase  )
									a__       :						List[Any]							=  model(_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase  )
									a__       :						Tuple							=  model(_lowerCAmelCase  )
									self.parent.assertEqual(result.last_hidden_state.shape ,       (self.batch_size, self.seq_length, self.hidden_size)  )
									self.parent.assertEqual(result.pooler_output.shape ,       (self.batch_size, self.hidden_size)  )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				int:
									"""simple docstring"""




									a__       :						Union[str, Any]							=  AlbertForPreTraining(config=_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						Optional[int]							=  model(
									    _lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase ,       labels=_lowerCAmelCase ,       sentence_order_label=_lowerCAmelCase ,       )
									self.parent.assertEqual(result.prediction_logits.shape ,       (self.batch_size, self.seq_length, self.vocab_size)  )
									self.parent.assertEqual(result.sop_logits.shape ,       (self.batch_size, config.num_labels)  )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				List[str]:
									"""simple docstring"""




									a__       :						Union[str, Any]							=  AlbertForMaskedLM(config=_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						Union[str, Any]							=  model(_lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase ,       labels=_lowerCAmelCase  )
									self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.seq_length, self.vocab_size)  )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				List[Any]:
									"""simple docstring"""




									a__       :						Tuple							=  AlbertForQuestionAnswering(config=_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						Dict							=  model(
									    _lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase ,       start_positions=_lowerCAmelCase ,       end_positions=_lowerCAmelCase ,       )
									self.parent.assertEqual(result.start_logits.shape ,       (self.batch_size, self.seq_length)  )
									self.parent.assertEqual(result.end_logits.shape ,       (self.batch_size, self.seq_length)  )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				Any:
									"""simple docstring"""




									a__       :						Dict							=  self.num_labels
									a__       :						Optional[Any]							=  AlbertForSequenceClassification(_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						Any							=  model(_lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase ,       labels=_lowerCAmelCase  )
									self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.num_labels)  )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				List[Any]:
									"""simple docstring"""




									a__       :						List[str]							=  self.num_labels
									a__       :						Dict							=  AlbertForTokenClassification(config=_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						List[str]							=  model(_lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase ,       labels=_lowerCAmelCase  )
									self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.seq_length, self.num_labels)  )

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase ,       __lowercase  ) ->				Union[str, Any]:
									"""simple docstring"""




									a__       :						Optional[Any]							=  self.num_choices
									a__       :						Union[str, Any]							=  AlbertForMultipleChoice(config=_lowerCAmelCase  )
									model.to(_lowerCAmelCase  )
									model.eval()
									a__       :						int							=  input_ids.unsqueeze(1  ).expand(-1 ,       self.num_choices ,       -1  ).contiguous()
									a__       :						Optional[Any]							=  token_type_ids.unsqueeze(1  ).expand(-1 ,       self.num_choices ,       -1  ).contiguous()
									a__       :						int							=  input_mask.unsqueeze(1  ).expand(-1 ,       self.num_choices ,       -1  ).contiguous()
									a__       :						List[Any]							=  model(
									    _lowerCAmelCase ,       attention_mask=_lowerCAmelCase ,       token_type_ids=_lowerCAmelCase ,       labels=_lowerCAmelCase ,       )
									self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.num_choices)  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Optional[Any]:
									"""simple docstring"""




									a__       :						int							=  self.prepare_config_and_inputs()
									(
									    a__				
									)       :						Any							=  config_and_inputs
									a__       :						Any							=  {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
									return config, inputs_dict




@require_torch
class        snake_case__    (__UpperCamelCase ,     __UpperCamelCase ,     unittest.TestCase		):







						"""simple docstring"""




						__lowerCAmelCase					:List[str]      =					(
						    (
						        AlbertModel,
						        AlbertForPreTraining,
						        AlbertForMaskedLM,
						        AlbertForMultipleChoice,
						        AlbertForSequenceClassification,
						        AlbertForTokenClassification,
						        AlbertForQuestionAnswering,
						    )
						    if is_torch_available()
						    else ()
						)
						__lowerCAmelCase					:Any      =					(
						    {
						        "feature-extraction": AlbertModel,
						        "fill-mask": AlbertForMaskedLM,
						        "question-answering": AlbertForQuestionAnswering,
						        "text-classification": AlbertForSequenceClassification,
						        "token-classification": AlbertForTokenClassification,
						        "zero-shot": AlbertForSequenceClassification,
						    }
						    if is_torch_available()
						    else {}
						)
						__lowerCAmelCase					:Tuple      =					True

						def 							SCREAMING_SNAKE_CASE__(       self ,       __lowercase ,       __lowercase ,       __lowercase=False  ) ->				int:
									"""simple docstring"""




									a__       :						Union[str, Any]							=  super()._prepare_for_class(_lowerCAmelCase ,       _lowerCAmelCase ,       return_labels=_lowerCAmelCase  )

									if return_labels:
												if model_class in get_values(_lowerCAmelCase  ):
															a__       :						Optional[Any]							=  torch.zeros(
															    (self.model_tester.batch_size, self.model_tester.seq_length) ,       dtype=torch.long ,       device=_lowerCAmelCase  )
															a__       :						Any							=  torch.zeros(
															    self.model_tester.batch_size ,       dtype=torch.long ,       device=_lowerCAmelCase  )
									return inputs_dict

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Any:
									"""simple docstring"""




									a__       :						Dict							=  AlbertModelTester(self  )
									a__       :						Union[str, Any]							=  ConfigTester(self ,       config_class=_lowerCAmelCase ,       hidden_size=3_7  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Any:
									"""simple docstring"""




									self.config_tester.run_common_tests()

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				str:
									"""simple docstring"""




									a__       :						Union[str, Any]							=  self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*_lowerCAmelCase  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				str:
									"""simple docstring"""




									a__       :						List[str]							=  self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_pretraining(*_lowerCAmelCase  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Union[str, Any]:
									"""simple docstring"""




									a__       :						int							=  self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_lm(*_lowerCAmelCase  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				str:
									"""simple docstring"""




									a__       :						Any							=  self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_multiple_choice(*_lowerCAmelCase  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Union[str, Any]:
									"""simple docstring"""




									a__       :						List[str]							=  self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_question_answering(*_lowerCAmelCase  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Optional[Any]:
									"""simple docstring"""




									a__       :						List[str]							=  self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_sequence_classification(*_lowerCAmelCase  )

						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Optional[Any]:
									"""simple docstring"""




									a__       :						Tuple							=  self.model_tester.prepare_config_and_inputs()
									for type in ["absolute", "relative_key", "relative_key_query"]:
												a__       :						List[str]							=  type
												self.model_tester.create_and_check_model(*_lowerCAmelCase  )

						@slow
						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				Dict:
									"""simple docstring"""




									for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												a__       :						Optional[Any]							=  AlbertModel.from_pretrained(_lowerCAmelCase  )
												self.assertIsNotNone(_lowerCAmelCase  )




@require_torch
class        snake_case__    (unittest.TestCase		):







						"""simple docstring"""




						@slow
						def 							SCREAMING_SNAKE_CASE__(       self  ) ->				List[Any]:
									"""simple docstring"""




									a__       :						str							=  AlbertModel.from_pretrained("""albert-base-v2"""  )
									a__       :						Optional[Any]							=  torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]  )
									a__       :						Optional[int]							=  torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
									with torch.no_grad():
												a__       :						Any							=  model(_lowerCAmelCase ,       attention_mask=_lowerCAmelCase  )[0]
									a__       :						Tuple							=  torch.Size((1, 1_1, 7_6_8)  )
									self.assertEqual(output.shape ,       _lowerCAmelCase  )
									a__       :						List[str]							=  torch.tensor(
									    [[[-0.6_5_1_3, 1.5_0_3_5, -0.2_7_6_6], [-0.6_5_1_5, 1.5_0_4_6, -0.2_7_8_0], [-0.6_5_1_2, 1.5_0_4_9, -0.2_7_8_4]]]  )

									self.assertTrue(torch.allclose(output[:, 1:4, 1:4] ,       _lowerCAmelCase ,       atol=1E-4  )  )









from __future__ import annotations

import math

def      lowerCAmelCase_					(  _lowercase    :       int)							->	list[int]:







			"""simple docstring"""

			if num <= 0:
						a__       :						Tuple							=  F'''{num}: Invalid input, please enter a positive integer.'''
						raise ValueError(_lowercase)

			a__       :						List[Any]							=  [True] * (num + 1)
			a__       :						List[str]							=  []
			a__       :						List[Any]							=  2
			a__       :						Optional[int]							=  int(math.sqrt(_lowercase))

			while start <= end:
						# If start is a prime
						if sieve[start] is True:
									prime.append(_lowercase)

									# Set multiples of start be False
									for i in range(start * start						,       num + 1						,       _lowercase):
												if sieve[i] is True:
															a__       :						Optional[int]							=  False

						start += 1

			for j in range(end + 1						,       num + 1):
						if sieve[j] is True:
									prime.append(_lowercase)

			return prime


if __name__ == "__main__":
		print(prime_sieve(int(input("Enter a positive integer: ").strip())))




