



def 	__a					(   lowerCAmelCase_       : int      ,lowerCAmelCase_       : int    )				->			float:






						'''simple docstring'''



						return base * power(lowerCAmelCase_      ,(exponent - 1)    ) if exponent else 1


if __name__ == "__main__":
	print('''Raise base to the power of exponent using recursion...''')
	__A       =						int(input('''Enter the base: ''').strip())
	__A       =						int(input('''Enter the exponent: ''').strip())
	__A       =						power(base, abs(exponent))
	if exponent < 0:  # power() does not properly deal w/ negative exponents
		__A       =						1 / result
	print(f'{base} to the power of {exponent} is {result}')









import unittest

from parameterized import parameterized

from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
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 (
	    GPTNeoXForCausalLM,
	    GPTNeoXForQuestionAnswering,
	    GPTNeoXForSequenceClassification,
	    GPTNeoXForTokenClassification,
	    GPTNeoXModel,
	)






class 		lowercase						:






	"""simple docstring"""


	def __init__(     self     :						Any						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						List[Any]=13						,  __UpperCAmelCase     :						Dict=7						,  __UpperCAmelCase     :						Optional[Any]=True						,  __UpperCAmelCase     :						Union[str, Any]=True						,  __UpperCAmelCase     :						Any=True						,  __UpperCAmelCase     :						Dict=True						,  __UpperCAmelCase     :						Dict=99						,  __UpperCAmelCase     :						Union[str, Any]=64						,  __UpperCAmelCase     :						Dict=5						,  __UpperCAmelCase     :						int=4						,  __UpperCAmelCase     :						int=37						,  __UpperCAmelCase     :						Dict="gelu"						,  __UpperCAmelCase     :						List[Any]=0.1						,  __UpperCAmelCase     :						int=0.1						,  __UpperCAmelCase     :						Union[str, Any]=512						,  __UpperCAmelCase     :						Any=16						,  __UpperCAmelCase     :						Union[str, Any]=2						,  __UpperCAmelCase     :						List[str]=0.02						,  __UpperCAmelCase     :						Union[str, Any]=3						,  __UpperCAmelCase     :						Tuple=4						,  __UpperCAmelCase     :						str=None						,  )      ->			str:
							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_=       vocab_size - 1




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]					)      ->			List[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
							if self.use_labels:
													UpperCAmelCase_=       ids_tensor([self.batch_size, self.seq_length]						,  self.num_labels					)

							UpperCAmelCase_=       self.get_config()

							return config, input_ids, input_mask, token_labels




	def   _SCREAMING_SNAKE_CASE		(     self     :						str					)      ->			Union[str, Any]:
							return GPTNeoXConfig(
							    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						,  is_decoder=__UpperCAmelCase						,  initializer_range=self.initializer_range						,  pad_token_id=self.pad_token_id						,  )




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			Optional[int]:
							UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_=       self.prepare_config_and_inputs()

							UpperCAmelCase_=       True

							return config, input_ids, input_mask, token_labels




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						Union[str, Any]					)      ->			Optional[int]:
							UpperCAmelCase_=       GPTNeoXModel(config=__UpperCAmelCase					)
							model.to(__UpperCAmelCase					)
							model.eval()
							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase					)
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, self.seq_length, self.hidden_size)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						Optional[Any]						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						Tuple					)      ->			Dict:
							UpperCAmelCase_=       True
							UpperCAmelCase_=       GPTNeoXModel(__UpperCAmelCase					)
							model.to(__UpperCAmelCase					)
							model.eval()
							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, self.seq_length, self.hidden_size)					)




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




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						List[Any]					)      ->			Union[str, Any]:
							UpperCAmelCase_=       self.num_labels
							UpperCAmelCase_=       GPTNeoXForQuestionAnswering(__UpperCAmelCase					)
							model.to(__UpperCAmelCase					)
							model.eval()
							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase					)
							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     :						Optional[int]						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						Optional[Any]						,  __UpperCAmelCase     :						List[str]					)      ->			Union[str, Any]:
							UpperCAmelCase_=       self.num_labels
							UpperCAmelCase_=       GPTNeoXForSequenceClassification(__UpperCAmelCase					)
							model.to(__UpperCAmelCase					)
							model.eval()
							UpperCAmelCase_=       ids_tensor([self.batch_size]						,  self.type_sequence_label_size					)
							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase						,  labels=__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.num_labels)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[int]						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Dict					)      ->			Dict:
							UpperCAmelCase_=       self.num_labels
							UpperCAmelCase_=       GPTNeoXForTokenClassification(__UpperCAmelCase					)
							model.to(__UpperCAmelCase					)
							model.eval()
							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase						,  labels=__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.seq_length, self.num_labels)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						int					)      ->			Optional[int]:
							UpperCAmelCase_=       True
							UpperCAmelCase_=       GPTNeoXForCausalLM(config=__UpperCAmelCase					)
							model.to(__UpperCAmelCase					)
							model.eval()

							# first forward pass
							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase						,  use_cache=__UpperCAmelCase					)
							UpperCAmelCase_=       outputs.past_key_values

							# create hypothetical multiple next token and extent to next_input_ids
							UpperCAmelCase_=       ids_tensor((self.batch_size, 3)						,  config.vocab_size					)
							UpperCAmelCase_=       ids_tensor((self.batch_size, 3)						,  vocab_size=2					)

							# append to next input_ids and
							UpperCAmelCase_=       torch.cat([input_ids, next_tokens]						,  dim=-1					)
							UpperCAmelCase_=       torch.cat([input_mask, next_mask]						,  dim=-1					)

							UpperCAmelCase_=       model(__UpperCAmelCase						,  attention_mask=__UpperCAmelCase						,  output_hidden_states=__UpperCAmelCase					)
							UpperCAmelCase_=       output_from_no_past["""hidden_states"""][0]
							UpperCAmelCase_=       model(
							    __UpperCAmelCase						,  attention_mask=__UpperCAmelCase						,  past_key_values=__UpperCAmelCase						,  output_hidden_states=__UpperCAmelCase						,  )["""hidden_states"""][0]

							# select random slice
							UpperCAmelCase_=       ids_tensor((1,)						,  output_from_past.shape[-1]					).item()
							UpperCAmelCase_=       output_from_no_past[:, -3:, random_slice_idx].detach()
							UpperCAmelCase_=       output_from_past[:, :, random_slice_idx].detach()

							self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]					)

							# test that outputs are equal for slice
							self.parent.assertTrue(torch.allclose(__UpperCAmelCase						,  __UpperCAmelCase						,  atol=1E-3					)					)




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






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






	"""simple docstring"""


	a__				: Union[str, Any]		       =							(
	    (
	        GPTNeoXModel,
	        GPTNeoXForCausalLM,
	        GPTNeoXForQuestionAnswering,
	        GPTNeoXForSequenceClassification,
	        GPTNeoXForTokenClassification,
	    )
	    if is_torch_available()
	    else ()
	)
	a__				: Any		       =							(GPTNeoXForCausalLM,) if is_torch_available() else ()
	a__				: str		       =							(
	    {
	        "feature-extraction": GPTNeoXModel,
	        "question-answering": GPTNeoXForQuestionAnswering,
	        "text-classification": GPTNeoXForSequenceClassification,
	        "text-generation": GPTNeoXForCausalLM,
	        "token-classification": GPTNeoXForTokenClassification,
	        "zero-shot": GPTNeoXForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)
	a__				: Optional[int]		       =							False
	a__				: Tuple		       =							False
	a__				: int		       =							False
	a__				: List[Any]		       =							False




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]					)      ->			Dict:
							UpperCAmelCase_=       GPTNeoXModelTester(self					)
							UpperCAmelCase_=       ConfigTester(self						,  config_class=__UpperCAmelCase						,  hidden_size=64						,  num_attention_heads=8					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[int]					)      ->			int:
							self.config_tester.run_common_tests()




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




	def   _SCREAMING_SNAKE_CASE		(     self     :						List[str]					)      ->			Union[str, Any]:
							UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs_for_decoder()
							self.model_tester.create_and_check_model_as_decoder(__UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			Tuple:
							# This regression test was failing with PyTorch < 1.3
							UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs_for_decoder()

							UpperCAmelCase_=       None

							self.model_tester.create_and_check_model_as_decoder(__UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Dict					)      ->			Union[str, Any]:
							UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_decoder_model_past_large_inputs(__UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any					)      ->			Any:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_causal_lm(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]					)      ->			int:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_question_answering(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			Union[str, Any]:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_sequence_classification(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						List[Any]					)      ->			List[Any]:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*__UpperCAmelCase					)




	@unittest.skip(reason="""Feed forward chunking is not implemented"""					)
	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			Union[str, Any]:
							pass




	@parameterized.expand([("""linear""",), ("""dynamic""",)]					)
	def   _SCREAMING_SNAKE_CASE		(     self     :						str						,  __UpperCAmelCase     :						Any					)      ->			Dict:
							UpperCAmelCase_,       UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs_for_common()
							UpperCAmelCase_=       ids_tensor([1, 10]						,  config.vocab_size					)
							UpperCAmelCase_=       ids_tensor([1, int(config.max_position_embeddings * 1.5					)]						,  config.vocab_size					)

							set_seed(42					)  # Fixed seed at init time so the two models get the same random weights
							UpperCAmelCase_=       GPTNeoXModel(__UpperCAmelCase					)
							original_model.to(__UpperCAmelCase					)
							original_model.eval()
							UpperCAmelCase_=       original_model(__UpperCAmelCase					).last_hidden_state
							UpperCAmelCase_=       original_model(__UpperCAmelCase					).last_hidden_state

							set_seed(42					)  # Fixed seed at init time so the two models get the same random weights
							UpperCAmelCase_=       {"""type""": scaling_type, """factor""": 10.0}
							UpperCAmelCase_=       GPTNeoXModel(__UpperCAmelCase					)
							scaled_model.to(__UpperCAmelCase					)
							scaled_model.eval()
							UpperCAmelCase_=       scaled_model(__UpperCAmelCase					).last_hidden_state
							UpperCAmelCase_=       scaled_model(__UpperCAmelCase					).last_hidden_state

							# Dynamic scaling does not change the RoPE embeddings until it receives an input longer than the original
							# maximum sequence length, so the outputs for the short input should match.
							if scaling_type == "dynamic":
													self.assertTrue(torch.allclose(__UpperCAmelCase						,  __UpperCAmelCase						,  atol=1E-5					)					)
							else:
													self.assertFalse(torch.allclose(__UpperCAmelCase						,  __UpperCAmelCase						,  atol=1E-5					)					)

							# The output should be different for long inputs
							self.assertFalse(torch.allclose(__UpperCAmelCase						,  __UpperCAmelCase						,  atol=1E-5					)					)






@require_torch
class 		lowercase						(			unittest.TestCase):






	"""simple docstring"""


	@slow
	def   _SCREAMING_SNAKE_CASE		(     self     :						int					)      ->			Tuple:
							UpperCAmelCase_=       AutoTokenizer.from_pretrained("""EleutherAI/pythia-410m-deduped"""					)
							for checkpointing in [True, False]:
													UpperCAmelCase_=       GPTNeoXForCausalLM.from_pretrained("""EleutherAI/pythia-410m-deduped"""					)

													if checkpointing:
																			model.gradient_checkpointing_enable()
													else:
																			model.gradient_checkpointing_disable()
													model.to(__UpperCAmelCase					)

													UpperCAmelCase_=       tokenizer("""My favorite food is"""						,  return_tensors="""pt"""					).to(__UpperCAmelCase					)
													# The hub repo. is updated on 2023-04-04, resulting in poor outputs.
													# See: https://github.com/huggingface/transformers/pull/24193
													UpperCAmelCase_=       """My favorite food is a good old-fashioned, old-fashioned, old-fashioned.\n\nI'm not sure"""

													UpperCAmelCase_=       model.generate(**__UpperCAmelCase						,  do_sample=__UpperCAmelCase						,  max_new_tokens=20					)
													UpperCAmelCase_=       tokenizer.batch_decode(__UpperCAmelCase					)[0]

													self.assertEqual(__UpperCAmelCase						,  __UpperCAmelCase					)




