




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 		UpperCAmelCase   (				unittest.TestCase			):







						'''simple docstring'''





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






							"""simple docstring"""






							snake_case_		    =     parent
							snake_case_		    =     batch_size
							snake_case_		    =     seq_length
							snake_case_		    =     is_training
							snake_case_		    =     use_attention_mask
							snake_case_		    =     use_token_type_ids
							snake_case_		    =     use_labels
							snake_case_		    =     vocab_size
							snake_case_		    =     hidden_size
							snake_case_		    =     num_hidden_layers
							snake_case_		    =     num_attention_heads
							snake_case_		    =     intermediate_size
							snake_case_		    =     hidden_act
							snake_case_		    =     hidden_dropout_prob
							snake_case_		    =     attention_probs_dropout_prob
							snake_case_		    =     max_position_embeddings
							snake_case_		    =     type_vocab_size
							snake_case_		    =     type_sequence_label_size
							snake_case_		    =     initializer_range
							snake_case_		    =     num_choices

							snake_case_		    =     rescale_embeddings
							snake_case_		    =     attention_type
							snake_case_		    =     use_bias
							snake_case_		    =     block_size
							snake_case_		    =     num_random_blocks






						def        snake_case__						(						self							:     Optional[int]						):






							"""simple docstring"""






							snake_case_		    =     ids_tensor([self.batch_size, self.seq_length]       ,	self.vocab_size						)

							snake_case_		    =     None
							if self.use_attention_mask:
								snake_case_		    =     random_attention_mask([self.batch_size, self.seq_length]						)

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

							snake_case_		    =     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=_a       ,	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        snake_case__						(						self							:     Optional[int]						):






							"""simple docstring"""






							snake_case_		    =     self.prepare_config_and_inputs()
							snake_case_		    =     config_and_inputs
							snake_case_		    =     {
							    'input_ids': input_ids,
							    'token_type_ids': token_type_ids,
							    'attention_mask': attention_mask,
							}
							return config, inputs_dict







@require_flax
class 		UpperCAmelCase   (				SCREAMING_SNAKE_CASE_       ,   unittest.TestCase			):







						'''simple docstring'''





						lowerCAmelCase_     		=   (
						    (
						        FlaxBigBirdForCausalLM,
						        FlaxBigBirdModel,
						        FlaxBigBirdForPreTraining,
						        FlaxBigBirdForMaskedLM,
						        FlaxBigBirdForMultipleChoice,
						        FlaxBigBirdForQuestionAnswering,
						        FlaxBigBirdForSequenceClassification,
						        FlaxBigBirdForTokenClassification,
						    )
						    if is_flax_available()
						    else ()
						)

						lowerCAmelCase_     		=   False
						lowerCAmelCase_     		=   False






						def        snake_case__						(						self							:     Tuple						):






							"""simple docstring"""






							snake_case_		    =     FlaxBigBirdModelTester(self						)






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






							"""simple docstring"""






							super().test_from_pretrained_save_pretrained()






						@slow
						# copied from `test_modeling_flax_common` because it takes much longer than other models
						def        snake_case__						(						self							:     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        snake_case__						(						self							:     Optional[int]						):






							"""simple docstring"""






							super().test_no_automatic_init()






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






							"""simple docstring"""






							super().test_hidden_states_output()






						@slow
						def        snake_case__						(						self							:     Optional[int]						):






							"""simple docstring"""






							for model_class_name in self.all_model_classes:
								snake_case_		    =     model_class_name.from_pretrained("google/bigbird-roberta-base"						)
								self.assertIsNotNone(_a						)






						def        snake_case__						(						self							:     Optional[Any]						):






							"""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        snake_case__						(						self							:     Optional[int]						):






							"""simple docstring"""






							snake_case_		    =     self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
								with self.subTest(model_class.__name__						):
									snake_case_		    =     self._prepare_for_class(_a       ,	_a						)
									snake_case_		    =     model_class(_a						)

									@jax.jit
									def model_jitted(__lowercase							:     Dict       ,	__lowercase							:     Any=None       ,	**__lowercase							:     Optional[int]						):
										return model(input_ids=_a       ,	attention_mask=_a       ,	**_a						)

									with self.subTest("JIT Enabled"						):
										snake_case_		    =     model_jitted(**_a						).to_tuple()

									with self.subTest("JIT Disabled"						):
										with jax.disable_jit():
											snake_case_		    =     model_jitted(**_a						).to_tuple()

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






						def        snake_case__						(						self							:     int       ,	__lowercase							:     Optional[Any]       ,	__lowercase							:     Optional[Any]       ,	__lowercase							:     Optional[int]       ,	__lowercase							:     Union[str, Any]=1E-5       ,	__lowercase							:     Dict="outputs"       ,	__lowercase							:     Any=None						):






							"""simple docstring"""






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





'''simple docstring'''





def        a_     (							_lowerCAmelCase       )      ->      list:
  if n_term == "":
    return []
  __lowerCamelCase       :       list           = []
  for temp in range(int(_lowerCAmelCase       )       ):
    series.append(F'1/{temp + 1}' if series else '1'       )
  return series


if __name__ == "__main__":
   _UpperCamelCase											=						input('Enter the last number (nth term) of the Harmonic Series')
   print('Formula of Harmonic Series => 1+1/2+1/3 ..... 1/n')
   print(harmonic_series(nth_term))






