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





		"""simple docstring"""





		def __init__(    self  ,					_snake_case  ,					_snake_case=13  ,					_snake_case=7  ,					_snake_case=True  ,					_snake_case=True  ,					_snake_case=True  ,					_snake_case=True  ,					_snake_case=99  ,					_snake_case=24  ,					_snake_case=32  ,					_snake_case=5  ,					_snake_case=4  ,					_snake_case=37  ,					_snake_case="gelu"  ,					_snake_case=0.1  ,					_snake_case=0.1  ,					_snake_case=512  ,					_snake_case=16  ,					_snake_case=2  ,					_snake_case=0.02  ,					_snake_case=4  ,					)				->    int:
				_UpperCamelCase       : List[Any]    =      parent
				_UpperCamelCase       : Optional[int]    =      batch_size
				_UpperCamelCase       : Dict    =      seq_length
				_UpperCamelCase       : Tuple    =      is_training
				_UpperCamelCase       : Dict    =      use_attention_mask
				_UpperCamelCase       : str    =      use_token_type_ids
				_UpperCamelCase       : Tuple    =      use_labels
				_UpperCamelCase       : str    =      vocab_size
				_UpperCamelCase       : Optional[int]    =      hidden_size
				_UpperCamelCase       : str    =      embedding_size
				_UpperCamelCase       : Tuple    =      num_hidden_layers
				_UpperCamelCase       : Optional[Any]    =      num_attention_heads
				_UpperCamelCase       : List[Any]    =      intermediate_size
				_UpperCamelCase       : str    =      hidden_act
				_UpperCamelCase       : Union[str, Any]    =      hidden_dropout_prob
				_UpperCamelCase       : Tuple    =      attention_probs_dropout_prob
				_UpperCamelCase       : Optional[int]    =      max_position_embeddings
				_UpperCamelCase       : Tuple    =      type_vocab_size
				_UpperCamelCase       : Dict    =      type_sequence_label_size
				_UpperCamelCase       : Tuple    =      initializer_range
				_UpperCamelCase       : List[Any]    =      num_choices
		def _lowercase  (    self     )				->    List[str]:
				_UpperCamelCase       : Tuple    =      ids_tensor([self.batch_size, self.seq_length]  ,					self.vocab_size     )

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

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

				_UpperCamelCase       : str    =      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 _lowercase  (    self     )				->    Optional[int]:
				_UpperCamelCase       : Tuple    =      self.prepare_config_and_inputs()
				_UpperCamelCase,							_UpperCamelCase,							_UpperCamelCase,							_UpperCamelCase       : int    =      config_and_inputs
				_UpperCamelCase       : List[Any]    =      {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
				return config, inputs_dict







@require_flax
class 			UpperCAmelCase				(					a_  ,		unittest.TestCase ):





		"""simple docstring"""





		A__  :   Optional[int]          =    True

		A__  :   List[str]          =    (
		    (
		        FlaxElectraModel,
		        FlaxElectraForCausalLM,
		        FlaxElectraForMaskedLM,
		        FlaxElectraForPreTraining,
		        FlaxElectraForTokenClassification,
		        FlaxElectraForQuestionAnswering,
		        FlaxElectraForMultipleChoice,
		        FlaxElectraForSequenceClassification,
		    )
		    if is_flax_available()
		    else ()
		)
		def _lowercase  (    self     )				->    int:
				_UpperCamelCase       : Union[str, Any]    =      FlaxElectraModelTester(self     )




		@slow
		def _lowercase  (    self     )				->    Optional[int]:
				for model_class_name in self.all_model_classes:
						if model_class_name == FlaxElectraForMaskedLM:
								_UpperCamelCase       : Optional[int]    =      model_class_name.from_pretrained('''google/electra-small-generator'''     )
						else:
								_UpperCamelCase       : Optional[Any]    =      model_class_name.from_pretrained('''google/electra-small-discriminator'''     )
						_UpperCamelCase       : str    =      model(np.ones((1, 1)     )     )
						self.assertIsNotNone(_snake_case     )







'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


_UpperCAmelCase   :      int 						=  {
    """configuration_gptsan_japanese""": ["""GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTSanJapaneseConfig"""],
    """tokenization_gptsan_japanese""": ["""GPTSanJapaneseTokenizer"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_UpperCAmelCase   :      int 						=  [
	    """GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """GPTSanJapaneseForConditionalGeneration""",
	    """GPTSanJapaneseModel""",
	    """GPTSanJapanesePreTrainedModel""",
	]
	_UpperCAmelCase   :      str 						=  [
	    """GPTSanJapaneseTokenizer""",
	]


if TYPE_CHECKING:
	from .configuration_gptsan_japanese import GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTSanJapaneseConfig
	from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_gptsan_japanese import (
		    GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
		    GPTSanJapaneseForConditionalGeneration,
		    GPTSanJapaneseModel,
		    GPTSanJapanesePreTrainedModel,
		)
		from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer


else:
	import sys

	_UpperCAmelCase   :      List[str] 						=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





