


import unittest

import numpy as np

from transformers import RoFormerConfig, 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.numpy as jnp

   from transformers.models.roformer.modeling_flax_roformer import (
       FlaxRoFormerForMaskedLM,
       FlaxRoFormerForMultipleChoice,
       FlaxRoFormerForQuestionAnswering,
       FlaxRoFormerForSequenceClassification,
       FlaxRoFormerForTokenClassification,
       FlaxRoFormerModel,
   )






class    UpperCAmelCase__	( unittest.TestCase		):



    """simple docstring"""






    def __init__(      self ,       A_ ,       A_=13 ,       A_=7 ,       A_=True ,       A_=True ,       A_=True ,       A_=True ,       A_=99 ,       A_=32 ,       A_=5 ,       A_=4 ,       A_=37 ,       A_="gelu" ,       A_=0.1 ,       A_=0.1 ,       A_=512 ,       A_=16 ,       A_=2 ,       A_=0.02 ,       A_=4 ,       )  ->	List[Any]:
         __UpperCamelCase   							=parent
         __UpperCamelCase   							=batch_size
         __UpperCamelCase   							=seq_length
         __UpperCamelCase   							=is_training
         __UpperCamelCase   							=use_attention_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_choices






    def _a (      self   )  ->	List[Any]:
         __UpperCamelCase   							=ids_tensor([self.batch_size, self.seq_length] ,       self.vocab_size   )

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

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

         __UpperCamelCase   							=RoFormerConfig(
             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 ,       )

         return config, input_ids, token_type_ids, attention_mask






    def _a (      self   )  ->	int:
         __UpperCamelCase   							=self.prepare_config_and_inputs()
         __UpperCamelCase   							=config_and_inputs
         __UpperCamelCase   							={'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"""






    UpperCAmelCase__						:		str              =  True

    UpperCAmelCase__						:		Optional[int]              =  (
        (
            FlaxRoFormerModel,
            FlaxRoFormerForMaskedLM,
            FlaxRoFormerForSequenceClassification,
            FlaxRoFormerForTokenClassification,
            FlaxRoFormerForMultipleChoice,
            FlaxRoFormerForQuestionAnswering,
        )
        if is_flax_available()
        else ()
    )






    def _a (      self   )  ->	Optional[int]:
         __UpperCamelCase   							=FlaxRoFormerModelTester(self   )






    @slow
    def _a (      self   )  ->	Tuple:
         for model_class_name in self.all_model_classes:
              __UpperCamelCase   							=model_class_name.from_pretrained('junnyu/roformer_chinese_small' ,       from_pt=A_   )
              __UpperCamelCase   							=model(np.ones((1, 1)   )   )
              self.assertIsNotNone(A_   )






@require_flax
class    UpperCAmelCase__	( unittest.TestCase		):



    """simple docstring"""






    @slow
    def _a (      self   )  ->	str:
         __UpperCamelCase   							=FlaxRoFormerForMaskedLM.from_pretrained('junnyu/roformer_chinese_base'   )
         __UpperCamelCase   							=jnp.array([[0, 1, 2, 3, 4, 5]]   )
         __UpperCamelCase   							=model(A_   )[0]

         __UpperCamelCase   							=50000

         __UpperCamelCase   							=(1, 6, vocab_size)
         self.assertEqual(output.shape ,       A_   )

         __UpperCamelCase   							=jnp.array(
             [[[-0.1205, -1.0265, 0.2922], [-1.5134, 0.1974, 0.1519], [-5.0135, -3.9003, -0.8404]]]   )

         self.assertTrue(jnp.allclose(output[:, :3, :3] ,       A_ ,       atol=1E-4   )   )









import pprint

import requests

_A			=						'https://zenquotes.io/api'

def 						_UpperCAmelCase    (      ):
     return requests.get(API_ENDPOINT_URL + '/today'    ).json()

def 						_UpperCAmelCase    (      ):
     return requests.get(API_ENDPOINT_URL + '/random'    ).json()


if __name__ == "__main__":
   _A			=						random_quotes()
   pprint.pprint(response)





