




"""simple docstring"""







import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format

class 				snake_case_			:







   """simple docstring"""




   A_				      =       None







   def   UpperCAmelCase__			(		self)				->   Optional[Any]:
       UpperCamelCase              =	self.feature_extraction_class(**self.feat_extract_dict)
       UpperCamelCase              =	json.loads(feat_extract.to_json_string())
       for key, value in self.feat_extract_dict.items():
           self.assertEqual(obj[key]       ,					lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   int:
       UpperCamelCase              =	self.feature_extraction_class(**self.feat_extract_dict)

       with tempfile.TemporaryDirectory() as tmpdirname:
           UpperCamelCase              =	os.path.join(lowerCamelCase_       ,					'''feat_extract.json''')
           feat_extract_first.to_json_file(lowerCamelCase_)
           UpperCamelCase              =	self.feature_extraction_class.from_json_file(lowerCamelCase_)

       self.assertEqual(feat_extract_second.to_dict()       ,					feat_extract_first.to_dict())







   def   UpperCAmelCase__			(		self)				->   int:
       UpperCamelCase              =	self.feature_extraction_class(**self.feat_extract_dict)

       with tempfile.TemporaryDirectory() as tmpdirname:
           UpperCamelCase              =	feat_extract_first.save_pretrained(lowerCamelCase_)[0]
           check_json_file_has_correct_format(lowerCamelCase_)
           UpperCamelCase              =	self.feature_extraction_class.from_pretrained(lowerCamelCase_)

       self.assertEqual(feat_extract_second.to_dict()       ,					feat_extract_first.to_dict())







   def   UpperCAmelCase__			(		self)				->   Union[str, Any]:
       UpperCamelCase              =	self.feature_extraction_class()
       self.assertIsNotNone(lowerCamelCase_)

"""simple docstring"""


from typing import TYPE_CHECKING

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


_lowercase				 =					{
    '''configuration_electra''': ['''ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ElectraConfig''', '''ElectraOnnxConfig'''],
    '''tokenization_electra''': ['''ElectraTokenizer'''],
}

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase				 =					['''ElectraTokenizerFast''']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase				 =					[
		    '''ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''ElectraForCausalLM''',
		    '''ElectraForMaskedLM''',
		    '''ElectraForMultipleChoice''',
		    '''ElectraForPreTraining''',
		    '''ElectraForQuestionAnswering''',
		    '''ElectraForSequenceClassification''',
		    '''ElectraForTokenClassification''',
		    '''ElectraModel''',
		    '''ElectraPreTrainedModel''',
		    '''load_tf_weights_in_electra''',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase				 =					[
		    '''TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''TFElectraForMaskedLM''',
		    '''TFElectraForMultipleChoice''',
		    '''TFElectraForPreTraining''',
		    '''TFElectraForQuestionAnswering''',
		    '''TFElectraForSequenceClassification''',
		    '''TFElectraForTokenClassification''',
		    '''TFElectraModel''',
		    '''TFElectraPreTrainedModel''',
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase				 =					[
		    '''FlaxElectraForCausalLM''',
		    '''FlaxElectraForMaskedLM''',
		    '''FlaxElectraForMultipleChoice''',
		    '''FlaxElectraForPreTraining''',
		    '''FlaxElectraForQuestionAnswering''',
		    '''FlaxElectraForSequenceClassification''',
		    '''FlaxElectraForTokenClassification''',
		    '''FlaxElectraModel''',
		    '''FlaxElectraPreTrainedModel''',
		]


if TYPE_CHECKING:
		from .configuration_electra import ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP, ElectraConfig, ElectraOnnxConfig
		from .tokenization_electra import ElectraTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_electra_fast import ElectraTokenizerFast

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_electra import (
				    ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
				    ElectraForCausalLM,
				    ElectraForMaskedLM,
				    ElectraForMultipleChoice,
				    ElectraForPreTraining,
				    ElectraForQuestionAnswering,
				    ElectraForSequenceClassification,
				    ElectraForTokenClassification,
				    ElectraModel,
				    ElectraPreTrainedModel,
				    load_tf_weights_in_electra,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_electra import (
				    TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFElectraForMaskedLM,
				    TFElectraForMultipleChoice,
				    TFElectraForPreTraining,
				    TFElectraForQuestionAnswering,
				    TFElectraForSequenceClassification,
				    TFElectraForTokenClassification,
				    TFElectraModel,
				    TFElectraPreTrainedModel,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_electra import (
				    FlaxElectraForCausalLM,
				    FlaxElectraForMaskedLM,
				    FlaxElectraForMultipleChoice,
				    FlaxElectraForPreTraining,
				    FlaxElectraForQuestionAnswering,
				    FlaxElectraForSequenceClassification,
				    FlaxElectraForTokenClassification,
				    FlaxElectraModel,
				    FlaxElectraPreTrainedModel,
				)

else:
		import sys

		_lowercase				 =					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)