

"""simple docstring"""






import unittest

from transformers import BigBirdConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
	import jax

	from transformers.models.big_bird.modeling_flax_big_bird import (
	    FlaxBigBirdForCausalLM,
	    FlaxBigBirdForMaskedLM,
	    FlaxBigBirdForMultipleChoice,
	    FlaxBigBirdForPreTraining,
	    FlaxBigBirdForQuestionAnswering,
	    FlaxBigBirdForSequenceClassification,
	    FlaxBigBirdForTokenClassification,
	    FlaxBigBirdModel,
	)







class       snake_case__  ( unittest.TestCase     ):







			def __init__(			self			: Optional[Any]			,  lowercase			: List[str]			,  lowercase			: str=2			,  lowercase			: Optional[Any]=56			,  lowercase			: List[Any]=True			,  lowercase			: int=True			,  lowercase			: Optional[Any]=True			,  lowercase			: Optional[int]=True			,  lowercase			: List[Any]=99			,  lowercase			: Union[str, Any]=32			,  lowercase			: Tuple=2			,  lowercase			: int=2			,  lowercase			: Union[str, Any]=7			,  lowercase			: int="gelu_new"			,  lowercase			: Optional[int]=0.1			,  lowercase			: Union[str, Any]=0.1			,  lowercase			: int=5_12			,  lowercase			: str=16			,  lowercase			: str=2			,  lowercase			: Any=0.0_2			,  lowercase			: str=4			,  lowercase			: int="block_sparse"			,  lowercase			: int=True			,  lowercase			: str=False			,  lowercase			: str=2			,  lowercase			: str=3			,  ):





								'''simple docstring'''



								UpperCAmelCase			:   Union[str, Any]      =				parent
								UpperCAmelCase			:   int      =				batch_size
								UpperCAmelCase			:   Optional[int]      =				seq_length
								UpperCAmelCase			:   Any      =				is_training
								UpperCAmelCase			:   Union[str, Any]      =				use_attention_mask
								UpperCAmelCase			:   List[Any]      =				use_token_type_ids
								UpperCAmelCase			:   Tuple      =				use_labels
								UpperCAmelCase			:   Any      =				vocab_size
								UpperCAmelCase			:   Union[str, Any]      =				hidden_size
								UpperCAmelCase			:   int      =				num_hidden_layers
								UpperCAmelCase			:   List[Any]      =				num_attention_heads
								UpperCAmelCase			:   Tuple      =				intermediate_size
								UpperCAmelCase			:   List[str]      =				hidden_act
								UpperCAmelCase			:   Tuple      =				hidden_dropout_prob
								UpperCAmelCase			:   Tuple      =				attention_probs_dropout_prob
								UpperCAmelCase			:   List[str]      =				max_position_embeddings
								UpperCAmelCase			:   Tuple      =				type_vocab_size
								UpperCAmelCase			:   int      =				type_sequence_label_size
								UpperCAmelCase			:   List[str]      =				initializer_range
								UpperCAmelCase			:   List[str]      =				num_choices

								UpperCAmelCase			:   Optional[Any]      =				rescale_embeddings
								UpperCAmelCase			:   Optional[int]      =				attention_type
								UpperCAmelCase			:   Tuple      =				use_bias
								UpperCAmelCase			:   List[str]      =				block_size
								UpperCAmelCase			:   Optional[Any]      =				num_random_blocks







			def 			__lowerCAmelCase				(			self			: Any  ):





								'''simple docstring'''



								UpperCAmelCase			:   Tuple      =				ids_tensor([self.batch_size, self.seq_length]			,  self.vocab_size  )

								UpperCAmelCase			:   Optional[int]      =				None
								if self.use_attention_mask:
													UpperCAmelCase			:   List[str]      =				random_attention_mask([self.batch_size, self.seq_length]  )

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

								UpperCAmelCase			:   Dict      =				BigBirdConfig(
								    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=lowercase			,  initializer_range=self.initializer_range			,  attention_type=self.attention_type			,  block_size=self.block_size			,  num_random_blocks=self.num_random_blocks			,  use_bias=self.use_bias			,  rescale_embeddings=self.rescale_embeddings			,  )

								return config, input_ids, token_type_ids, attention_mask







			def 			__lowerCAmelCase				(			self			: int  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				self.prepare_config_and_inputs()
								UpperCAmelCase      ,							UpperCAmelCase      ,							UpperCAmelCase      ,							UpperCAmelCase			:   Tuple      =				config_and_inputs
								UpperCAmelCase			:   int      =				{
								    "input_ids": input_ids,
								    "token_type_ids": token_type_ids,
								    "attention_mask": attention_mask,
								}
								return config, inputs_dict







@require_flax
class       snake_case__  ( lowerCAmelCase_					,  unittest.TestCase     ):
			SCREAMING_SNAKE_CASE__     				=						(
			    (
			        FlaxBigBirdForCausalLM,
			        FlaxBigBirdModel,
			        FlaxBigBirdForPreTraining,
			        FlaxBigBirdForMaskedLM,
			        FlaxBigBirdForMultipleChoice,
			        FlaxBigBirdForQuestionAnswering,
			        FlaxBigBirdForSequenceClassification,
			        FlaxBigBirdForTokenClassification,
			    )
			    if is_flax_available()
			    else ()
			)

			SCREAMING_SNAKE_CASE__     				=						False
			SCREAMING_SNAKE_CASE__     				=						False







			def 			__lowerCAmelCase				(			self			: List[str]  ):





								'''simple docstring'''



								UpperCAmelCase			:   int      =				FlaxBigBirdModelTester(self  )







			@slow
			# copied from `test_modeling_flax_common` because it takes much longer than other models
			def 			__lowerCAmelCase				(			self			: Union[str, Any]  ):





								'''simple docstring'''



								super().test_from_pretrained_save_pretrained()







			@slow
			# copied from `test_modeling_flax_common` because it takes much longer than other models
			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								super().test_from_pretrained_with_no_automatic_init()







			@slow
			# copied from `test_modeling_flax_common` because it takes much longer than other models
			def 			__lowerCAmelCase				(			self			: Union[str, Any]  ):





								'''simple docstring'''



								super().test_no_automatic_init()







			@slow
			# copied from `test_modeling_flax_common` because it takes much longer than other models
			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								super().test_hidden_states_output()







			@slow
			def 			__lowerCAmelCase				(			self			: Tuple  ):





								'''simple docstring'''



								for model_class_name in self.all_model_classes:
													UpperCAmelCase			:   Optional[int]      =				model_class_name.from_pretrained("google/bigbird-roberta-base"  )
													self.assertIsNotNone(lowercase  )







			def 			__lowerCAmelCase				(			self			: Dict  ):





								'''simple docstring'''



								if self.test_attn_probs:
													super().test_attention_outputs()







			@slow
			# copied from `test_modeling_flax_common` because it takes much longer than other models
			def 			__lowerCAmelCase				(			self			: Any  ):





								'''simple docstring'''



								UpperCAmelCase      ,							UpperCAmelCase			:   List[str]      =				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
													with self.subTest(model_class.__name__  ):
																		UpperCAmelCase			:   Any      =				self._prepare_for_class(lowercase			,  lowercase  )
																		UpperCAmelCase			:   int      =				model_class(lowercase  )

																		@jax.jit
																		def model_jitted(lowercase			: str			,  lowercase			: List[Any]=None			,  **lowercase			: List[Any]  ):
																							return model(input_ids=lowercase			,  attention_mask=lowercase			,  **lowercase  )

																		with self.subTest("JIT Enabled"  ):
																							UpperCAmelCase			:   int      =				model_jitted(**lowercase  ).to_tuple()

																		with self.subTest("JIT Disabled"  ):
																							with jax.disable_jit():
																												UpperCAmelCase			:   List[Any]      =				model_jitted(**lowercase  ).to_tuple()

																		self.assertEqual(len(lowercase  )			,  len(lowercase  )  )
																		for jitted_output, output in zip(lowercase			,  lowercase  ):
																							self.assertEqual(jitted_output.shape			,  output.shape  )







			def 			__lowerCAmelCase				(			self			: str			,  lowercase			: List[Any]			,  lowercase			: Dict			,  lowercase			: List[str]			,  lowercase			: Optional[Any]=1E-5			,  lowercase			: List[str]="outputs"			,  lowercase			: List[Any]=None  ):





								'''simple docstring'''



								if name.startswith("outputs.attentions"  ):
													return
								else:
													super().check_pt_flax_outputs(lowercase			,  lowercase			,  lowercase			,  lowercase			,  lowercase			,  lowercase  )








"""simple docstring"""






def   lowercase_	(    _lowercase       :		str	):




					'''simple docstring'''






					if not all(x.isalpha() for x in string	):
										raise ValueError("String must only contain alphabetic characters."	)

					UpperCAmelCase			:   Optional[int]      =				sorted(string.lower()	)
					return len(_lowercase	) == len(set(_lowercase	)	)


if __name__ == "__main__":
	snake_case_   :   Tuple        =       input("""Enter a string """).strip()

	snake_case_   :   str        =       is_isogram(input_str)
	print(f'''{input_str} is {"an" if isogram else "not an"} isogram.''')


