



from collections import OrderedDict
from typing import Mapping

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


a_								=   logging.get_logger(__name__)

a_								=   {
    """squeezebert/squeezebert-uncased""": (
        """https://huggingface.co/squeezebert/squeezebert-uncased/resolve/main/config.json"""
    ),
    """squeezebert/squeezebert-mnli""": """https://huggingface.co/squeezebert/squeezebert-mnli/resolve/main/config.json""",
    """squeezebert/squeezebert-mnli-headless""": (
        """https://huggingface.co/squeezebert/squeezebert-mnli-headless/resolve/main/config.json"""
    ),
}



class 	__lowerCAmelCase       (		lowerCAmelCase__				):
	lowerCAmelCase__       =					SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
	lowerCAmelCase__       =					"""squeezebert"""




	def __init__(  self		,			__UpperCAmelCase=30522		,			__UpperCAmelCase=768		,			__UpperCAmelCase=12		,			__UpperCAmelCase=12		,			__UpperCAmelCase=3072		,			__UpperCAmelCase="gelu"		,			__UpperCAmelCase=0.1		,			__UpperCAmelCase=0.1		,			__UpperCAmelCase=512		,			__UpperCAmelCase=2		,			__UpperCAmelCase=0.02		,			__UpperCAmelCase=1E-1_2		,			__UpperCAmelCase=0		,			__UpperCAmelCase=768		,			__UpperCAmelCase=4		,			__UpperCAmelCase=4		,			__UpperCAmelCase=4		,			__UpperCAmelCase=1		,			__UpperCAmelCase=4		,			__UpperCAmelCase=4		,			**__UpperCAmelCase		,			):



				'''simple docstring'''
				super().__init__(pad_token_id=__UpperCAmelCase		,			**__UpperCAmelCase			)

				__lowerCamelCase  							=      vocab_size
				__lowerCamelCase  							=      hidden_size
				__lowerCamelCase  							=      num_hidden_layers
				__lowerCamelCase  							=      num_attention_heads
				__lowerCamelCase  							=      hidden_act
				__lowerCamelCase  							=      intermediate_size
				__lowerCamelCase  							=      hidden_dropout_prob
				__lowerCamelCase  							=      attention_probs_dropout_prob
				__lowerCamelCase  							=      max_position_embeddings
				__lowerCamelCase  							=      type_vocab_size
				__lowerCamelCase  							=      initializer_range
				__lowerCamelCase  							=      layer_norm_eps
				__lowerCamelCase  							=      embedding_size
				__lowerCamelCase  							=      q_groups
				__lowerCamelCase  							=      k_groups
				__lowerCamelCase  							=      v_groups
				__lowerCamelCase  							=      post_attention_groups
				__lowerCamelCase  							=      intermediate_groups
				__lowerCamelCase  							=      output_groups



class 	__lowerCAmelCase       (		lowerCAmelCase__				):




	@property
	def     lowerCamelCase (  self			):



				'''simple docstring'''
				if self.task == "multiple-choice":
							__lowerCamelCase  							=      {0: '''batch''', 1: '''choice''', 2: '''sequence'''}
				else:
							__lowerCamelCase  							=      {0: '''batch''', 1: '''sequence'''}
				return OrderedDict(
				    [
				        ('''input_ids''', dynamic_axis),
				        ('''attention_mask''', dynamic_axis),
				        ('''token_type_ids''', dynamic_axis),
				    ]			)











import unittest

import numpy as np

from transformers import ElectraConfig, 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():
  from transformers.models.electra.modeling_flax_electra import (
      FlaxElectraForCausalLM,
      FlaxElectraForMaskedLM,
      FlaxElectraForMultipleChoice,
      FlaxElectraForPreTraining,
      FlaxElectraForQuestionAnswering,
      FlaxElectraForSequenceClassification,
      FlaxElectraForTokenClassification,
      FlaxElectraModel,
  )



class 	__lowerCAmelCase       (		unittest.TestCase				):




 def __init__(  self		,			__UpperCAmelCase		,			__UpperCAmelCase=13		,			__UpperCAmelCase=7		,			__UpperCAmelCase=True		,			__UpperCAmelCase=True		,			__UpperCAmelCase=True		,			__UpperCAmelCase=True		,			__UpperCAmelCase=99		,			__UpperCAmelCase=24		,			__UpperCAmelCase=32		,			__UpperCAmelCase=5		,			__UpperCAmelCase=4		,			__UpperCAmelCase=37		,			__UpperCAmelCase="gelu"		,			__UpperCAmelCase=0.1		,			__UpperCAmelCase=0.1		,			__UpperCAmelCase=512		,			__UpperCAmelCase=16		,			__UpperCAmelCase=2		,			__UpperCAmelCase=0.02		,			__UpperCAmelCase=4		,			):



    '''simple docstring'''
    __lowerCamelCase  							=      parent
    __lowerCamelCase  							=      batch_size
    __lowerCamelCase  							=      seq_length
    __lowerCamelCase  							=      is_training
    __lowerCamelCase  							=      use_attention_mask
    __lowerCamelCase  							=      use_token_type_ids
    __lowerCamelCase  							=      use_labels
    __lowerCamelCase  							=      vocab_size
    __lowerCamelCase  							=      hidden_size
    __lowerCamelCase  							=      embedding_size
    __lowerCamelCase  							=      num_hidden_layers
    __lowerCamelCase  							=      num_attention_heads
    __lowerCamelCase  							=      intermediate_size
    __lowerCamelCase  							=      hidden_act
    __lowerCamelCase  							=      hidden_dropout_prob
    __lowerCamelCase  							=      attention_probs_dropout_prob
    __lowerCamelCase  							=      max_position_embeddings
    __lowerCamelCase  							=      type_vocab_size
    __lowerCamelCase  							=      type_sequence_label_size
    __lowerCamelCase  							=      initializer_range
    __lowerCamelCase  							=      num_choices




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      ids_tensor([self.batch_size, self.seq_length]		,			self.vocab_size			)

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

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

    __lowerCamelCase  							=      ElectraConfig(
        vocab_size=self.vocab_size		,			hidden_size=self.hidden_size		,			embedding_size=self.embedding_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		,			initializer_range=self.initializer_range		,			)

    return config, input_ids, token_type_ids, attention_mask




 def     lowerCamelCase (  self			):



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



@require_flax
class 	__lowerCAmelCase       (		lowerCAmelCase__					,		unittest.TestCase				):
 lowerCAmelCase__       =					True

 lowerCAmelCase__       =					(
     (
         FlaxElectraModel,
         FlaxElectraForCausalLM,
         FlaxElectraForMaskedLM,
         FlaxElectraForPreTraining,
         FlaxElectraForTokenClassification,
         FlaxElectraForQuestionAnswering,
         FlaxElectraForMultipleChoice,
         FlaxElectraForSequenceClassification,
     )
     if is_flax_available()
     else ()
 )




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      FlaxElectraModelTester(self			)




 @slow
 def     lowerCamelCase (  self			):



    '''simple docstring'''
    for model_class_name in self.all_model_classes:
       if model_class_name == FlaxElectraForMaskedLM:
          __lowerCamelCase  							=      model_class_name.from_pretrained('''google/electra-small-generator'''			)
       else:
          __lowerCamelCase  							=      model_class_name.from_pretrained('''google/electra-small-discriminator'''			)
       __lowerCamelCase  							=      model(np.ones((1, 1)			)			)
       self.assertIsNotNone(__UpperCAmelCase			)






