


"""simple docstring"""






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 			SCREAMING_SNAKE_CASE_  (   unittest.TestCase):




							'''simple docstring'''





							def __init__(						self	,					lowerCamelCase__	,					lowerCamelCase__=13	,					lowerCamelCase__=7	,					lowerCamelCase__=True	,					lowerCamelCase__=True	,					lowerCamelCase__=True	,					lowerCamelCase__=True	,					lowerCamelCase__=99	,					lowerCamelCase__=24	,					lowerCamelCase__=32	,					lowerCamelCase__=5	,					lowerCamelCase__=4	,					lowerCamelCase__=37	,					lowerCamelCase__="gelu"	,					lowerCamelCase__=0.1	,					lowerCamelCase__=0.1	,					lowerCamelCase__=512	,					lowerCamelCase__=16	,					lowerCamelCase__=2	,					lowerCamelCase__=0.02	,					lowerCamelCase__=4	,					)   ->	Optional[Any]:







								'''simple docstring'''




								snake_case__  :						Optional[int]		=      parent
								snake_case__  :						int		=      batch_size
								snake_case__  :						str		=      seq_length
								snake_case__  :						Optional[int]		=      is_training
								snake_case__  :						Union[str, Any]		=      use_attention_mask
								snake_case__  :						List[str]		=      use_token_type_ids
								snake_case__  :						Tuple		=      use_labels
								snake_case__  :						Optional[int]		=      vocab_size
								snake_case__  :						Union[str, Any]		=      hidden_size
								snake_case__  :						Union[str, Any]		=      embedding_size
								snake_case__  :						Optional[int]		=      num_hidden_layers
								snake_case__  :						List[Any]		=      num_attention_heads
								snake_case__  :						Any		=      intermediate_size
								snake_case__  :						Any		=      hidden_act
								snake_case__  :						Optional[Any]		=      hidden_dropout_prob
								snake_case__  :						int		=      attention_probs_dropout_prob
								snake_case__  :						Optional[int]		=      max_position_embeddings
								snake_case__  :						List[Any]		=      type_vocab_size
								snake_case__  :						Optional[int]		=      type_sequence_label_size
								snake_case__  :						Any		=      initializer_range
								snake_case__  :						Dict		=      num_choices




							def        UpperCAmelCase (						self)   ->	str:







								'''simple docstring'''




								snake_case__  :						int		=      ids_tensor([self.batch_size, self.seq_length]	,					self.vocab_size)

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

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

								snake_case__  :						Tuple		=      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        UpperCAmelCase (						self)   ->	Dict:







								'''simple docstring'''




								snake_case__  :						Any		=      self.prepare_config_and_inputs()
								snake_case__  :						List[str]		=      config_and_inputs
								snake_case__  :						Tuple		=      {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
								return config, inputs_dict


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




							'''simple docstring'''





							__magic_name__					:     Dict				  =  True

							__magic_name__					:     List[Any]				  =  (
							    (
							        FlaxElectraModel,
							        FlaxElectraForCausalLM,
							        FlaxElectraForMaskedLM,
							        FlaxElectraForPreTraining,
							        FlaxElectraForTokenClassification,
							        FlaxElectraForQuestionAnswering,
							        FlaxElectraForMultipleChoice,
							        FlaxElectraForSequenceClassification,
							    )
							    if is_flax_available()
							    else ()
							)




							def        UpperCAmelCase (						self)   ->	Tuple:







								'''simple docstring'''




								snake_case__  :						Optional[Any]		=      FlaxElectraModelTester(self)







							@slow
							def        UpperCAmelCase (						self)   ->	Tuple:







								'''simple docstring'''




								for model_class_name in self.all_model_classes:
									if model_class_name == FlaxElectraForMaskedLM:
										snake_case__  :						str		=      model_class_name.from_pretrained("google/electra-small-generator")
									else:
										snake_case__  :						List[str]		=      model_class_name.from_pretrained("google/electra-small-discriminator")
									snake_case__  :						int		=      model(np.ones((1, 1)))
									self.assertIsNotNone(lowerCamelCase__)











'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available


lowercase						:   int      						=							{
    '''configuration_xlm_prophetnet''': ['''XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMProphetNetConfig'''],
}

try:
      if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase						:   Any      						=							['''XLMProphetNetTokenizer''']

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase						:   Tuple      						=							[
          '''XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
          '''XLMProphetNetDecoder''',
          '''XLMProphetNetEncoder''',
          '''XLMProphetNetForCausalLM''',
          '''XLMProphetNetForConditionalGeneration''',
          '''XLMProphetNetModel''',
          '''XLMProphetNetPreTrainedModel''',
      ]


if TYPE_CHECKING:
      from .configuration_xlm_prophetnet import XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMProphetNetConfig

      try:
            if not is_sentencepiece_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_xlm_prophetnet import XLMProphetNetTokenizer

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_xlm_prophetnet import (
                XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST,
                XLMProphetNetDecoder,
                XLMProphetNetEncoder,
                XLMProphetNetForCausalLM,
                XLMProphetNetForConditionalGeneration,
                XLMProphetNetModel,
                XLMProphetNetPreTrainedModel,
            )

else:
      import sys

      lowercase						:   Optional[Any]      						=							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




