



"""simple docstring"""


import unittest

from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, 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 (
				    SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    SqueezeBertForMaskedLM,
				    SqueezeBertForMultipleChoice,
				    SqueezeBertForQuestionAnswering,
				    SqueezeBertForSequenceClassification,
				    SqueezeBertForTokenClassification,
				    SqueezeBertModel,
				)







class       A_			(     SCREAMING_SNAKE_CASE_				):



						"""simple docstring"""






						def __init__(					self :Optional[Any]   ,  lowercase_ :int   ,  lowercase_ :Tuple=13   ,  lowercase_ :Any=7   ,  lowercase_ :List[str]=True   ,  lowercase_ :Optional[int]=True   ,  lowercase_ :str=False   ,  lowercase_ :Optional[int]=True   ,  lowercase_ :Union[str, Any]=99   ,  lowercase_ :Optional[int]=32   ,  lowercase_ :int=5   ,  lowercase_ :int=4   ,  lowercase_ :Optional[int]=64   ,  lowercase_ :Union[str, Any]="gelu"   ,  lowercase_ :Union[str, Any]=0.1   ,  lowercase_ :List[Any]=0.1   ,  lowercase_ :Union[str, Any]=5_12   ,  lowercase_ :Tuple=16   ,  lowercase_ :Union[str, Any]=2   ,  lowercase_ :Optional[Any]=0.02   ,  lowercase_ :Union[str, Any]=3   ,  lowercase_ :int=4   ,  lowercase_ :Any=None   ,  lowercase_ :Any=2   ,  lowercase_ :List[Any]=2   ,  lowercase_ :Optional[Any]=2   ,  lowercase_ :Any=2   ,  lowercase_ :int=4   ,  lowercase_ :Optional[int]=1   ,  )				->			int:
												UpperCAmelCase             = parent
												UpperCAmelCase             = batch_size
												UpperCAmelCase             = seq_length
												UpperCAmelCase             = is_training
												UpperCAmelCase             = use_input_mask
												UpperCAmelCase             = use_token_type_ids
												UpperCAmelCase             = use_labels
												UpperCAmelCase             = vocab_size
												UpperCAmelCase             = hidden_size
												UpperCAmelCase             = num_hidden_layers
												UpperCAmelCase             = num_attention_heads
												UpperCAmelCase             = intermediate_size
												UpperCAmelCase             = hidden_act
												UpperCAmelCase             = hidden_dropout_prob
												UpperCAmelCase             = attention_probs_dropout_prob
												UpperCAmelCase             = max_position_embeddings
												UpperCAmelCase             = type_vocab_size
												UpperCAmelCase             = type_sequence_label_size
												UpperCAmelCase             = initializer_range
												UpperCAmelCase             = num_labels
												UpperCAmelCase             = num_choices
												UpperCAmelCase             = scope
												UpperCAmelCase             = q_groups
												UpperCAmelCase             = k_groups
												UpperCAmelCase             = v_groups
												UpperCAmelCase             = post_attention_groups
												UpperCAmelCase             = intermediate_groups
												UpperCAmelCase             = output_groups






						def 	UpperCAmelCase__     (					self :Optional[Any]					)				->			Union[str, Any]:
												UpperCAmelCase             = ids_tensor([self.batch_size, self.seq_length]   ,  self.vocab_size					)

												UpperCAmelCase             = None
												if self.use_input_mask:
																		UpperCAmelCase             = random_attention_mask([self.batch_size, self.seq_length]					)

												UpperCAmelCase             = None
												UpperCAmelCase             = None
												UpperCAmelCase             = None
												if self.use_labels:
																		UpperCAmelCase             = ids_tensor([self.batch_size]   ,  self.type_sequence_label_size					)
																		UpperCAmelCase             = ids_tensor([self.batch_size, self.seq_length]   ,  self.num_labels					)
																		UpperCAmelCase             = ids_tensor([self.batch_size]   ,  self.num_choices					)

												UpperCAmelCase             = self.get_config()

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






						def 	UpperCAmelCase__     (					self :Optional[int]					)				->			Optional[Any]:
												return SqueezeBertConfig(
												    embedding_size=self.hidden_size   ,  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   ,  attention_probs_dropout_prob=self.hidden_dropout_prob   ,  attention_dropout=self.attention_probs_dropout_prob   ,  max_position_embeddings=self.max_position_embeddings   ,  initializer_range=self.initializer_range   ,  q_groups=self.q_groups   ,  k_groups=self.k_groups   ,  v_groups=self.v_groups   ,  post_attention_groups=self.post_attention_groups   ,  intermediate_groups=self.intermediate_groups   ,  output_groups=self.output_groups   ,  )






						def 	UpperCAmelCase__     (					self :Optional[Any]   ,  lowercase_ :List[str]   ,  lowercase_ :Optional[Any]   ,  lowercase_ :Tuple   ,  lowercase_ :Any   ,  lowercase_ :Dict   ,  lowercase_ :Tuple					)				->			str:
												UpperCAmelCase             = SqueezeBertModel(config=lowercase_					)
												model.to(lowercase_					)
												model.eval()
												UpperCAmelCase             = model(lowercase_   ,  lowercase_					)
												UpperCAmelCase             = model(lowercase_					)
												self.parent.assertEqual(result.last_hidden_state.shape   ,  (self.batch_size, self.seq_length, self.hidden_size)					)






						def 	UpperCAmelCase__     (					self :List[Any]   ,  lowercase_ :Optional[int]   ,  lowercase_ :str   ,  lowercase_ :Tuple   ,  lowercase_ :List[Any]   ,  lowercase_ :Dict   ,  lowercase_ :Any					)				->			int:
												UpperCAmelCase             = SqueezeBertForMaskedLM(config=lowercase_					)
												model.to(lowercase_					)
												model.eval()
												UpperCAmelCase             = model(lowercase_   ,  attention_mask=lowercase_   ,  labels=lowercase_					)
												self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.seq_length, self.vocab_size)					)






						def 	UpperCAmelCase__     (					self :List[str]   ,  lowercase_ :List[Any]   ,  lowercase_ :Optional[int]   ,  lowercase_ :Union[str, Any]   ,  lowercase_ :Optional[int]   ,  lowercase_ :Dict   ,  lowercase_ :List[str]					)				->			Dict:
												UpperCAmelCase             = SqueezeBertForQuestionAnswering(config=lowercase_					)
												model.to(lowercase_					)
												model.eval()
												UpperCAmelCase             = model(
												    lowercase_   ,  attention_mask=lowercase_   ,  start_positions=lowercase_   ,  end_positions=lowercase_					)
												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 	UpperCAmelCase__     (					self :List[Any]   ,  lowercase_ :str   ,  lowercase_ :List[str]   ,  lowercase_ :int   ,  lowercase_ :str   ,  lowercase_ :Optional[int]   ,  lowercase_ :Union[str, Any]					)				->			int:
												UpperCAmelCase             = self.num_labels
												UpperCAmelCase             = SqueezeBertForSequenceClassification(lowercase_					)
												model.to(lowercase_					)
												model.eval()
												UpperCAmelCase             = model(lowercase_   ,  attention_mask=lowercase_   ,  labels=lowercase_					)
												self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.num_labels)					)






						def 	UpperCAmelCase__     (					self :List[str]   ,  lowercase_ :List[str]   ,  lowercase_ :Any   ,  lowercase_ :Any   ,  lowercase_ :Dict   ,  lowercase_ :Optional[int]   ,  lowercase_ :Tuple					)				->			Any:
												UpperCAmelCase             = self.num_labels
												UpperCAmelCase             = SqueezeBertForTokenClassification(config=lowercase_					)
												model.to(lowercase_					)
												model.eval()

												UpperCAmelCase             = model(lowercase_   ,  attention_mask=lowercase_   ,  labels=lowercase_					)
												self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.seq_length, self.num_labels)					)






						def 	UpperCAmelCase__     (					self :int   ,  lowercase_ :Dict   ,  lowercase_ :Any   ,  lowercase_ :Tuple   ,  lowercase_ :Optional[Any]   ,  lowercase_ :int   ,  lowercase_ :str					)				->			int:
												UpperCAmelCase             = self.num_choices
												UpperCAmelCase             = SqueezeBertForMultipleChoice(config=lowercase_					)
												model.to(lowercase_					)
												model.eval()
												UpperCAmelCase             = input_ids.unsqueeze(1					).expand(-1   ,  self.num_choices   ,  -1					).contiguous()
												UpperCAmelCase             = input_mask.unsqueeze(1					).expand(-1   ,  self.num_choices   ,  -1					).contiguous()
												UpperCAmelCase             = model(
												    lowercase_   ,  attention_mask=lowercase_   ,  labels=lowercase_   ,  )
												self.parent.assertEqual(result.logits.shape   ,  (self.batch_size, self.num_choices)					)






						def 	UpperCAmelCase__     (					self :Optional[Any]					)				->			Tuple:
												UpperCAmelCase             = self.prepare_config_and_inputs()
												((UpperCAmelCase)      ,    (UpperCAmelCase)      ,    (UpperCAmelCase)      ,    (UpperCAmelCase)      ,    (UpperCAmelCase)      ,    (UpperCAmelCase))             = config_and_inputs
												UpperCAmelCase             = {'input_ids': input_ids, 'attention_mask': input_mask}
												return config, inputs_dict







@require_torch
class       A_			(     SCREAMING_SNAKE_CASE_	,   SCREAMING_SNAKE_CASE_	,   unittest.TestCase				):



						"""simple docstring"""
						__UpperCamelCase						=							(
						    (
						        SqueezeBertModel,
						        SqueezeBertForMaskedLM,
						        SqueezeBertForMultipleChoice,
						        SqueezeBertForQuestionAnswering,
						        SqueezeBertForSequenceClassification,
						        SqueezeBertForTokenClassification,
						    )
						    if is_torch_available()
						    else None
						)
						__UpperCamelCase						=							(
						    {
						        """feature-extraction""": SqueezeBertModel,
						        """fill-mask""": SqueezeBertForMaskedLM,
						        """question-answering""": SqueezeBertForQuestionAnswering,
						        """text-classification""": SqueezeBertForSequenceClassification,
						        """token-classification""": SqueezeBertForTokenClassification,
						        """zero-shot""": SqueezeBertForSequenceClassification,
						    }
						    if is_torch_available()
						    else {}
						)
						__UpperCamelCase						=							False
						__UpperCamelCase						=							True
						__UpperCamelCase						=							False






						def 	UpperCAmelCase__     (					self :str					)				->			Dict:
												UpperCAmelCase             = SqueezeBertModelTester(self					)
												UpperCAmelCase             = ConfigTester(self   ,  config_class=lowercase_   ,  dim=37					)






						def 	UpperCAmelCase__     (					self :int					)				->			Dict:
												self.config_tester.run_common_tests()






						def 	UpperCAmelCase__     (					self :List[str]					)				->			Tuple:
												UpperCAmelCase             = self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_squeezebert_model(*lowercase_					)






						def 	UpperCAmelCase__     (					self :Optional[Any]					)				->			List[str]:
												UpperCAmelCase             = self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_squeezebert_for_masked_lm(*lowercase_					)






						def 	UpperCAmelCase__     (					self :List[Any]					)				->			Dict:
												UpperCAmelCase             = self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_squeezebert_for_question_answering(*lowercase_					)






						def 	UpperCAmelCase__     (					self :str					)				->			Union[str, Any]:
												UpperCAmelCase             = self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_squeezebert_for_sequence_classification(*lowercase_					)






						def 	UpperCAmelCase__     (					self :List[Any]					)				->			Optional[Any]:
												UpperCAmelCase             = self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_squeezebert_for_token_classification(*lowercase_					)






						def 	UpperCAmelCase__     (					self :List[str]					)				->			Any:
												UpperCAmelCase             = self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_squeezebert_for_multiple_choice(*lowercase_					)






						@slow
						def 	UpperCAmelCase__     (					self :Dict					)				->			List[str]:
												for model_name in SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		UpperCAmelCase             = SqueezeBertModel.from_pretrained(lowercase_					)
																		self.assertIsNotNone(lowercase_					)







@require_sentencepiece
@require_tokenizers
@require_torch
class       A_			(     unittest.TestCase				):



						"""simple docstring"""






						@slow
						def 	UpperCAmelCase__     (					self :Tuple					)				->			int:
												UpperCAmelCase             = SqueezeBertForSequenceClassification.from_pretrained('squeezebert/squeezebert-mnli'					)

												UpperCAmelCase             = torch.tensor([[1, 2_94_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 13, 15_88, 2]]					)
												UpperCAmelCase             = model(lowercase_					)[0]
												UpperCAmelCase             = torch.Size((1, 3)					)
												self.assertEqual(output.shape   ,  lowercase_					)
												UpperCAmelCase             = torch.tensor([[0.6401, -0.0349, -0.6041]]					)
												self.assertTrue(torch.allclose(lowercase_   ,  lowercase_   ,  atol=1E-4					)					)







from math import ceil


def     __lowerCAmelCase			(			a__ = 1001  )       ->  int:
				__a										=    1

				for i in range(1						,    int(ceil(n / 2.0  )  )  ):
								__a										=    2 * i + 1
								__a										=    2 * i
								__a										=    total + 4 * odd**2 - 6 * even

				return total


if __name__ == "__main__":
					import sys

					if len(sys.argv) == 1:
										print(solution())
					else:
										try:
															A     :	List[Any]    = int(sys.argv[1])
															print(solution(n))
										except ValueError:
															print('Invalid entry - please enter a number')