



'''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 					lowerCamelCase_    (				unittest.TestCase     ):
  """simple docstring"""




  def __init__( self      :	Union[str, Any]			,	_a      :	Dict			,	_a      :	Any=2			,	_a      :	List[Any]=56			,	_a      :	Optional[int]=True			,	_a      :	Tuple=True			,	_a      :	Any=True			,	_a      :	List[str]=True			,	_a      :	Dict=99			,	_a      :	str=32			,	_a      :	Optional[Any]=2			,	_a      :	List[str]=2			,	_a      :	Tuple=7			,	_a      :	Any="gelu_new"			,	_a      :	Union[str, Any]=0.1			,	_a      :	List[Any]=0.1			,	_a      :	Optional[Any]=512			,	_a      :	Dict=16			,	_a      :	List[str]=2			,	_a      :	List[Any]=0.02			,	_a      :	int=4			,	_a      :	Dict="block_sparse"			,	_a      :	Optional[Any]=True			,	_a      :	List[Any]=False			,	_a      :	Any=2			,	_a      :	Optional[int]=3			,	)					->					Dict:
    __lowerCamelCase       :       Optional[int]           = parent
    __lowerCamelCase       :       Optional[Any]           = batch_size
    __lowerCamelCase       :       Union[str, Any]           = seq_length
    __lowerCamelCase       :       Optional[Any]           = is_training
    __lowerCamelCase       :       Tuple           = use_attention_mask
    __lowerCamelCase       :       Optional[int]           = use_token_type_ids
    __lowerCamelCase       :       List[str]           = use_labels
    __lowerCamelCase       :       str           = vocab_size
    __lowerCamelCase       :       Tuple           = hidden_size
    __lowerCamelCase       :       List[Any]           = num_hidden_layers
    __lowerCamelCase       :       Union[str, Any]           = num_attention_heads
    __lowerCamelCase       :       int           = intermediate_size
    __lowerCamelCase       :       Tuple           = hidden_act
    __lowerCamelCase       :       Optional[Any]           = hidden_dropout_prob
    __lowerCamelCase       :       int           = attention_probs_dropout_prob
    __lowerCamelCase       :       Dict           = max_position_embeddings
    __lowerCamelCase       :       List[str]           = type_vocab_size
    __lowerCamelCase       :       List[str]           = type_sequence_label_size
    __lowerCamelCase       :       Optional[Any]           = initializer_range
    __lowerCamelCase       :       Tuple           = num_choices

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




  def 						_lowercase     ( self      :	Optional[int]   )					->					int:
    __lowerCamelCase       :       Dict           = ids_tensor([self.batch_size, self.seq_length]			,	self.vocab_size   )

    __lowerCamelCase       :       Any           = None
    if self.use_attention_mask:
      __lowerCamelCase       :       Optional[int]           = random_attention_mask([self.batch_size, self.seq_length]   )

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

    __lowerCamelCase       :       str           = 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 						_lowercase     ( self      :	Optional[int]   )					->					List[str]:
    __lowerCamelCase       :       Optional[Any]           = self.prepare_config_and_inputs()
    __lowerCamelCase       ,__lowerCamelCase       ,__lowerCamelCase       ,__lowerCamelCase       :       Any           = config_and_inputs
    __lowerCamelCase       :       Optional[int]           = {
        'input_ids': input_ids,
        'token_type_ids': token_type_ids,
        'attention_mask': attention_mask,
    }
    return config, inputs_dict






@require_flax
class 					lowerCamelCase_    (				SCREAMING_SNAKE_CASE_   ,   unittest.TestCase     ):
  """simple docstring"""




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

  a_												=False
  a_												=False




  def 						_lowercase     ( self      :	Tuple   )					->					Union[str, Any]:
    __lowerCamelCase       :       Any           = FlaxBigBirdModelTester(self   )




  @slow
  # copied from `test_modeling_flax_common` because it takes much longer than other models
  def 						_lowercase     ( self      :	int   )					->					List[str]:
    super().test_from_pretrained_save_pretrained()




  @slow
  # copied from `test_modeling_flax_common` because it takes much longer than other models
  def 						_lowercase     ( self      :	Any   )					->					Tuple:
    super().test_from_pretrained_with_no_automatic_init()




  @slow
  # copied from `test_modeling_flax_common` because it takes much longer than other models
  def 						_lowercase     ( self      :	Optional[int]   )					->					Dict:
    super().test_no_automatic_init()




  @slow
  # copied from `test_modeling_flax_common` because it takes much longer than other models
  def 						_lowercase     ( self      :	List[str]   )					->					Union[str, Any]:
    super().test_hidden_states_output()




  @slow
  def 						_lowercase     ( self      :	Optional[int]   )					->					List[Any]:
    for model_class_name in self.all_model_classes:
      __lowerCamelCase       :       str           = model_class_name.from_pretrained('google/bigbird-roberta-base'   )
      self.assertIsNotNone(_a   )




  def 						_lowercase     ( self      :	Optional[Any]   )					->					int:
    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 						_lowercase     ( self      :	Optional[int]   )					->					Optional[int]:
    __lowerCamelCase       ,__lowerCamelCase       :       Dict           = self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
      with self.subTest(model_class.__name__   ):
        __lowerCamelCase       :       List[Any]           = self._prepare_for_class(_a			,	_a   )
        __lowerCamelCase       :       Union[str, Any]           = model_class(_a   )

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

        with self.subTest('JIT Enabled'   ):
          __lowerCamelCase       :       Tuple           = model_jitted(**_a   ).to_tuple()

        with self.subTest('JIT Disabled'   ):
          with jax.disable_jit():
            __lowerCamelCase       :       Optional[int]           = 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 						_lowercase     ( self      :	int			,	_a      :	Optional[Any]			,	_a      :	Optional[Any]			,	_a      :	Optional[int]			,	_a      :	Union[str, Any]=1e-5			,	_a      :	Dict="outputs"			,	_a      :	Any=None   )					->					List[str]:
    # `bigbird_block_sparse_attention` in `FlaxBigBird` returns `attention_probs = None`, while in PyTorch version,
    # an effort was done to return `attention_probs` (yet to be verified).
    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))






