



'''simple docstring'''





from __future__ import annotations

import unittest

from transformers import is_tf_available, is_torch_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow


if is_tf_available():
	from transformers import (
	    AutoConfig,
	    BertConfig,
	    GPTaConfig,
	    TaConfig,
	    TFAutoModel,
	    TFAutoModelForCausalLM,
	    TFAutoModelForMaskedLM,
	    TFAutoModelForPreTraining,
	    TFAutoModelForQuestionAnswering,
	    TFAutoModelForSeqaSeqLM,
	    TFAutoModelForSequenceClassification,
	    TFAutoModelWithLMHead,
	    TFBertForMaskedLM,
	    TFBertForPreTraining,
	    TFBertForQuestionAnswering,
	    TFBertForSequenceClassification,
	    TFBertModel,
	    TFGPTaLMHeadModel,
	    TFRobertaForMaskedLM,
	    TFTaForConditionalGeneration,
	)
	from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST

if is_torch_available():
	from transformers import (
	    AutoModel,
	    AutoModelForCausalLM,
	    AutoModelForMaskedLM,
	    AutoModelForPreTraining,
	    AutoModelForQuestionAnswering,
	    AutoModelForSeqaSeqLM,
	    AutoModelForSequenceClassification,
	    AutoModelWithLMHead,
	    BertForMaskedLM,
	    BertForPreTraining,
	    BertForQuestionAnswering,
	    BertForSequenceClassification,
	    BertModel,
	    GPTaLMHeadModel,
	    RobertaForMaskedLM,
	    TaForConditionalGeneration,
	)

@is_pt_tf_cross_test
class   _A   ( unittest.TestCase	):


						'''simple docstring'''





						@slow
						def     _snake_case	(	self	:							Optional[int]	):






							'''simple docstring'''



							for model_name in ["bert-base-uncased"]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModel.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModel.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							str	):






							'''simple docstring'''



							for model_name in ["bert-base-uncased"]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelForPreTraining.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelForPreTraining.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							int	):






							'''simple docstring'''



							for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelForCausalLM.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								__lowercase       ,    __lowercase		       =			TFAutoModelForCausalLM.from_pretrained(
								    lowerCamelCase							,      output_loading_info=lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelForCausalLM.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								__lowercase       ,    __lowercase		       =			AutoModelForCausalLM.from_pretrained(
								    lowerCamelCase							,      output_loading_info=lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							Union[str, Any]	):






							'''simple docstring'''



							for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelWithLMHead.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelWithLMHead.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							Tuple	):






							'''simple docstring'''



							for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelForMaskedLM.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								__lowercase       ,    __lowercase		       =			TFAutoModelForMaskedLM.from_pretrained(
								    lowerCamelCase							,      output_loading_info=lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelForMaskedLM.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								__lowercase       ,    __lowercase		       =			AutoModelForMaskedLM.from_pretrained(
								    lowerCamelCase							,      output_loading_info=lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							str	):






							'''simple docstring'''



							for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelForSeqaSeqLM.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								__lowercase       ,    __lowercase		       =			TFAutoModelForSeqaSeqLM.from_pretrained(
								    lowerCamelCase							,      output_loading_info=lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelForSeqaSeqLM.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								__lowercase       ,    __lowercase		       =			AutoModelForSeqaSeqLM.from_pretrained(
								    lowerCamelCase							,      output_loading_info=lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							List[Any]	):






							'''simple docstring'''



							for model_name in ["bert-base-uncased"]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelForSequenceClassification.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelForSequenceClassification.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						@slow
						def     _snake_case	(	self	:							Union[str, Any]	):






							'''simple docstring'''



							for model_name in ["bert-base-uncased"]:
								__lowercase		       =			AutoConfig.from_pretrained(lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			TFAutoModelForQuestionAnswering.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)

								__lowercase		       =			AutoModelForQuestionAnswering.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
								self.assertIsNotNone(lowerCamelCase	)
								self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)



						def     _snake_case	(	self	:							Optional[Any]	):






							'''simple docstring'''



							__lowercase		       =			TFAutoModelWithLMHead.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
							self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)
							self.assertEqual(model.num_parameters()							,      14_410	)
							self.assertEqual(model.num_parameters(only_trainable=lowerCamelCase	)							,      14_410	)

							__lowercase		       =			AutoModelWithLMHead.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
							self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)
							self.assertEqual(model.num_parameters()							,      14_410	)
							self.assertEqual(model.num_parameters(only_trainable=lowerCamelCase	)							,      14_410	)



						def     _snake_case	(	self	:							List[str]	):






							'''simple docstring'''



							__lowercase		       =			TFAutoModelWithLMHead.from_pretrained(lowerCamelCase							,      from_pt=lowerCamelCase	)
							self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)
							self.assertEqual(model.num_parameters()							,      14_410	)
							self.assertEqual(model.num_parameters(only_trainable=lowerCamelCase	)							,      14_410	)

							__lowercase		       =			AutoModelWithLMHead.from_pretrained(lowerCamelCase							,      from_tf=lowerCamelCase	)
							self.assertIsInstance(lowerCamelCase							,      lowerCamelCase	)
							self.assertEqual(model.num_parameters()							,      14_410	)
							self.assertEqual(model.num_parameters(only_trainable=lowerCamelCase	)							,      14_410	)








# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


snake_case__					:     List[str]    		=   {
    """configuration_mgp_str""": ["""MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MgpstrConfig"""],
    """processing_mgp_str""": ["""MgpstrProcessor"""],
    """tokenization_mgp_str""": ["""MgpstrTokenizer"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case__					:     Dict    		=   [
	    """MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """MgpstrModel""",
	    """MgpstrPreTrainedModel""",
	    """MgpstrForSceneTextRecognition""",
	]

if TYPE_CHECKING:
	from .configuration_mgp_str import MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP, MgpstrConfig
	from .processing_mgp_str import MgpstrProcessor
	from .tokenization_mgp_str import MgpstrTokenizer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_mgp_str import (
		    MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST,
		    MgpstrForSceneTextRecognition,
		    MgpstrModel,
		    MgpstrPreTrainedModel,
		)
else:
	import sys

	snake_case__					:     Union[str, Any]    		=   _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



