






import unittest

from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow


if is_flax_available():
   import jax

   from transformers.models.auto.modeling_flax_auto import FlaxAutoModel
   from transformers.models.bert.modeling_flax_bert import FlaxBertModel
   from transformers.models.roberta.modeling_flax_roberta import FlaxRobertaModel




@require_flax
class     _lowerCAmelCase(	unittest.TestCase ):





       """simple docstring"""







       @slow
       def       _a   ( self							):
         for model_name in ["bert-base-cased", "bert-large-uncased"]:
           with self.subTest(_lowerCamelCase							):
             UpperCamelCase_: Dict   				=    AutoConfig.from_pretrained(_lowerCamelCase							)
             self.assertIsNotNone(_lowerCamelCase							)
             self.assertIsInstance(_lowerCamelCase  ,      _lowerCamelCase							)

             UpperCamelCase_: List[Any]   				=    FlaxAutoModel.from_pretrained(_lowerCamelCase							)
             self.assertIsNotNone(_lowerCamelCase							)
             self.assertIsInstance(_lowerCamelCase  ,      _lowerCamelCase							)





       @slow
       def       _a   ( self							):
         for model_name in ["roberta-base", "roberta-large"]:
           with self.subTest(_lowerCamelCase							):
             UpperCamelCase_: Tuple   				=    AutoConfig.from_pretrained(_lowerCamelCase							)
             self.assertIsNotNone(_lowerCamelCase							)
             self.assertIsInstance(_lowerCamelCase  ,      _lowerCamelCase							)

             UpperCamelCase_: Union[str, Any]   				=    FlaxAutoModel.from_pretrained(_lowerCamelCase							)
             self.assertIsNotNone(_lowerCamelCase							)
             self.assertIsInstance(_lowerCamelCase  ,      _lowerCamelCase							)





       @slow
       def       _a   ( self							):
         for model_name in ["bert-base-cased", "bert-large-uncased"]:
           UpperCamelCase_: int   				=    AutoTokenizer.from_pretrained(_lowerCamelCase							)
           UpperCamelCase_: Any   				=    FlaxBertModel.from_pretrained(_lowerCamelCase							)
           UpperCamelCase_: List[str]   				=    tokenizer('Do you support jax jitted function?'  ,      return_tensors=TensorType.JAX							)

           @jax.jit
           def eval(**_lowerCamelCase							):
             return model(**_lowerCamelCase							)

           eval(**_lowerCamelCase							).block_until_ready()





       @slow
       def       _a   ( self							):
         for model_name in ["roberta-base", "roberta-large"]:
           UpperCamelCase_: List[Any]   				=    AutoTokenizer.from_pretrained(_lowerCamelCase							)
           UpperCamelCase_: Any   				=    FlaxRobertaModel.from_pretrained(_lowerCamelCase							)
           UpperCamelCase_: str   				=    tokenizer('Do you support jax jitted function?'  ,      return_tensors=TensorType.JAX							)

           @jax.jit
           def eval(**_lowerCamelCase							):
             return model(**_lowerCamelCase							)

           eval(**_lowerCamelCase							).block_until_ready()





       def       _a   ( self							):
         with self.assertRaisesRegex(
             _lowerCamelCase  ,      'bert-base is not a local folder and is not a valid model identifier'							):
           UpperCamelCase_: Any   				=    FlaxAutoModel.from_pretrained('bert-base'							)





       def       _a   ( self							):
         with self.assertRaisesRegex(
             _lowerCamelCase  ,      r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'							):
           UpperCamelCase_: int   				=    FlaxAutoModel.from_pretrained(_lowerCamelCase  ,      revision='aaaaaa'							)





       def       _a   ( self							):
         with self.assertRaisesRegex(
             _lowerCamelCase  ,      'hf-internal-testing/config-no-model does not appear to have a file named flax_model.msgpack'  ,      ):
           UpperCamelCase_: List[str]   				=    FlaxAutoModel.from_pretrained('hf-internal-testing/config-no-model'							)





       def       _a   ( self							):
         with self.assertRaisesRegex(_lowerCamelCase  ,      'Use `from_pt=True` to load this model'							):
           UpperCamelCase_: Union[str, Any]   				=    FlaxAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only'							)







from collections import OrderedDict
from typing import Mapping

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


A_		:		List[Any]		     =			logging.get_logger(__name__)

A_		:		Optional[Any]		     =			{
    'YituTech/conv-bert-base': 'https://huggingface.co/YituTech/conv-bert-base/resolve/main/config.json',
    'YituTech/conv-bert-medium-small': (
        'https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/config.json'
    ),
    'YituTech/conv-bert-small': 'https://huggingface.co/YituTech/conv-bert-small/resolve/main/config.json',
    # See all ConvBERT models at https://huggingface.co/models?filter=convbert
}




class     _lowerCAmelCase(	UpperCAmelCase_ ):





       """simple docstring"""







       a    :		str									='''convbert'''





       def __init__( self  ,      _lowerCamelCase=3_0_5_2_2  ,      _lowerCamelCase=7_6_8  ,      _lowerCamelCase=1_2  ,      _lowerCamelCase=1_2  ,      _lowerCamelCase=3_0_7_2  ,      _lowerCamelCase="gelu"  ,      _lowerCamelCase=0.1  ,      _lowerCamelCase=0.1  ,      _lowerCamelCase=5_1_2  ,      _lowerCamelCase=2  ,      _lowerCamelCase=0.0_2  ,      _lowerCamelCase=1e-12  ,      _lowerCamelCase=1  ,      _lowerCamelCase=0  ,      _lowerCamelCase=2  ,      _lowerCamelCase=7_6_8  ,      _lowerCamelCase=2  ,      _lowerCamelCase=9  ,      _lowerCamelCase=1  ,      _lowerCamelCase=None  ,      **_lowerCamelCase  ,      ):
         super().__init__(
             pad_token_id=_lowerCamelCase  ,      bos_token_id=_lowerCamelCase  ,      eos_token_id=_lowerCamelCase  ,      **_lowerCamelCase  ,      )

         UpperCamelCase_: Dict   				=    vocab_size
         UpperCamelCase_: Tuple   				=    hidden_size
         UpperCamelCase_: Optional[int]   				=    num_hidden_layers
         UpperCamelCase_: Optional[int]   				=    num_attention_heads
         UpperCamelCase_: Optional[Any]   				=    intermediate_size
         UpperCamelCase_: Tuple   				=    hidden_act
         UpperCamelCase_: Any   				=    hidden_dropout_prob
         UpperCamelCase_: Any   				=    attention_probs_dropout_prob
         UpperCamelCase_: List[Any]   				=    max_position_embeddings
         UpperCamelCase_: List[Any]   				=    type_vocab_size
         UpperCamelCase_: Optional[int]   				=    initializer_range
         UpperCamelCase_: Tuple   				=    layer_norm_eps
         UpperCamelCase_: List[str]   				=    embedding_size
         UpperCamelCase_: int   				=    head_ratio
         UpperCamelCase_: Dict   				=    conv_kernel_size
         UpperCamelCase_: List[Any]   				=    num_groups
         UpperCamelCase_: Dict   				=    classifier_dropout







class     _lowerCAmelCase(	UpperCAmelCase_ ):





       """simple docstring"""







       @property
       def       _a   ( self							):
         if self.task == "multiple-choice":
           UpperCamelCase_: Dict   				=    {0: 'batch', 1: 'choice', 2: 'sequence'}
         else:
           UpperCamelCase_: Dict   				=    {0: 'batch', 1: 'sequence'}
         return OrderedDict(
             [
                 ('input_ids', dynamic_axis),
                 ('attention_mask', dynamic_axis),
                 ('token_type_ids', dynamic_axis),
             ]							)