





'''simple docstring'''

import unittest

import numpy as np

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

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
    from transformers.models.bert.modeling_flax_bert import (
        FlaxBertForMaskedLM,
        FlaxBertForMultipleChoice,
        FlaxBertForNextSentencePrediction,
        FlaxBertForPreTraining,
        FlaxBertForQuestionAnswering,
        FlaxBertForSequenceClassification,
        FlaxBertForTokenClassification,
        FlaxBertModel,
    )







class __a			( unittest.TestCase      ):





   def __init__(       self					:      List[Any]					,lowerCamelCase					:      List[str]					,lowerCamelCase					:      Optional[Any]=13					,lowerCamelCase					:      List[str]=7					,lowerCamelCase					:      Optional[Any]=True					,lowerCamelCase					:      List[str]=True					,lowerCamelCase					:      int=True					,lowerCamelCase					:      Any=True					,lowerCamelCase					:      List[str]=99					,lowerCamelCase					:      List[str]=32					,lowerCamelCase					:      str=5					,lowerCamelCase					:      int=4					,lowerCamelCase					:      Any=37					,lowerCamelCase					:      List[Any]="gelu"					,lowerCamelCase					:      List[Any]=0.1					,lowerCamelCase					:      str=0.1					,lowerCamelCase					:      str=512					,lowerCamelCase					:      Union[str, Any]=16					,lowerCamelCase					:      List[str]=2					,lowerCamelCase					:      Tuple=0.02					,lowerCamelCase					:      int=4					,):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

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

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

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

      __SCREAMING_SNAKE_CASE   				=							BertConfig(
          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=lowerCamelCase					,initializer_range=self.initializer_range					,)

      return config, input_ids, token_type_ids, attention_mask





   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      Tuple     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							self.prepare_config_and_inputs()
      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							config_and_inputs

      __SCREAMING_SNAKE_CASE   				=							True
      __SCREAMING_SNAKE_CASE   				=							floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
      __SCREAMING_SNAKE_CASE   				=							ids_tensor([self.batch_size, self.seq_length]					,vocab_size=2     )

      return (
          config,
          input_ids,
          attention_mask,
          encoder_hidden_states,
          encoder_attention_mask,
      )







@require_flax
class __a			( _snake_case, unittest.TestCase      ):
   __UpperCamelCase :			Dict						   =						True

   __UpperCamelCase :			List[Any]						   =						(
       (
           FlaxBertModel,
           FlaxBertForPreTraining,
           FlaxBertForMaskedLM,
           FlaxBertForMultipleChoice,
           FlaxBertForQuestionAnswering,
           FlaxBertForNextSentencePrediction,
           FlaxBertForSequenceClassification,
           FlaxBertForTokenClassification,
           FlaxBertForQuestionAnswering,
       )
       if is_flax_available()
       else ()
   )





   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							FlaxBertModelTester(self     )





   @slow
   def   UpperCAmelCase__  (       self					:      Dict     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							FlaxBertModel.from_pretrained("""bert-base-cased"""     )
      __SCREAMING_SNAKE_CASE   				=							model(np.ones((1, 1)     )     )
      self.assertIsNotNone(lowerCamelCase     )









'''simple docstring'''





from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase__  			=				logging.get_logger(__name__)

UpperCAmelCase__  			=				{
    '''roberta-base''': '''https://huggingface.co/roberta-base/resolve/main/config.json''',
    '''roberta-large''': '''https://huggingface.co/roberta-large/resolve/main/config.json''',
    '''roberta-large-mnli''': '''https://huggingface.co/roberta-large-mnli/resolve/main/config.json''',
    '''distilroberta-base''': '''https://huggingface.co/distilroberta-base/resolve/main/config.json''',
    '''roberta-base-openai-detector''': '''https://huggingface.co/roberta-base-openai-detector/resolve/main/config.json''',
    '''roberta-large-openai-detector''': '''https://huggingface.co/roberta-large-openai-detector/resolve/main/config.json''',
}
class 						a__					(					a_   ):





			'''simple docstring'''

			A						:				Union[str, Any]					      =			'''roberta'''
			def __init__(  self							:			Any			,    lowerCAmelCase_							:			int=50_265			,    lowerCAmelCase_							:			int=768			,    lowerCAmelCase_							:			Optional[Any]=12			,    lowerCAmelCase_							:			Tuple=12			,    lowerCAmelCase_							:			Optional[int]=3_072			,    lowerCAmelCase_							:			List[str]="gelu"			,    lowerCAmelCase_							:			List[str]=0.1			,    lowerCAmelCase_							:			Tuple=0.1			,    lowerCAmelCase_							:			List[Any]=512			,    lowerCAmelCase_							:			Union[str, Any]=2			,    lowerCAmelCase_							:			List[Any]=0.02			,    lowerCAmelCase_							:			Optional[int]=1E-12			,    lowerCAmelCase_							:			str=1			,    lowerCAmelCase_							:			Dict=0			,    lowerCAmelCase_							:			Any=2			,    lowerCAmelCase_							:			List[str]="absolute"			,    lowerCAmelCase_							:			Any=True			,    lowerCAmelCase_							:			Dict=None			,    **lowerCAmelCase_							:			Any			,    )      ->		int:
						super().__init__(pad_token_id=lowerCAmelCase_			,    bos_token_id=lowerCAmelCase_			,    eos_token_id=lowerCAmelCase_			,    **lowerCAmelCase_	)

						__A=	vocab_size
						__A=	hidden_size
						__A=	num_hidden_layers
						__A=	num_attention_heads
						__A=	hidden_act
						__A=	intermediate_size
						__A=	hidden_dropout_prob
						__A=	attention_probs_dropout_prob
						__A=	max_position_embeddings
						__A=	type_vocab_size
						__A=	initializer_range
						__A=	layer_norm_eps
						__A=	position_embedding_type
						__A=	use_cache
						__A=	classifier_dropout


class 						a__					(					a_   ):





			'''simple docstring'''

			@property
			def 					lowerCAmelCase     (  self							:			Any	)      ->		Mapping[str, Mapping[int, str]]:
						if self.task == "multiple-choice":
									__A=	{0: 'batch', 1: 'choice', 2: 'sequence'}
						else:
									__A=	{0: 'batch', 1: 'sequence'}
						return OrderedDict(
						    [
						        ('input_ids', dynamic_axis),
						        ('attention_mask', dynamic_axis),
						    ]	)



