





# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# 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.

# this script dumps information about the environment

import os
import platform
import sys


UpperCamelCase__   : str					  = """3"""

print("""Python version:""", sys.version)

print("""OS platform:""", platform.platform())
print("""OS architecture:""", platform.machine())

try:
				import torch

				print("""Torch version:""", torch.__version__)
				print("""Cuda available:""", torch.cuda.is_available())
				print("""Cuda version:""", torch.version.cuda)
				print("""CuDNN version:""", torch.backends.cudnn.version())
				print("""Number of GPUs available:""", torch.cuda.device_count())
except ImportError:
				print("""Torch version:""", None)

try:
				import transformers

				print("""transformers version:""", transformers.__version__)
except ImportError:
				print("""transformers version:""", None)









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







					'''simple docstring'''

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






						'''simple docstring'''







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

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

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





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






						'''simple docstring'''







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

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

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





					@slow
					def        SCREAMING_SNAKE_CASE							(						self    :  Any		):






						'''simple docstring'''







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

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

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





					@slow
					def        SCREAMING_SNAKE_CASE							(						self    :  Optional[Any]		):






						'''simple docstring'''







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

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

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





					@slow
					def        SCREAMING_SNAKE_CASE							(						self    :  str		):






						'''simple docstring'''







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

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

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





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






						'''simple docstring'''







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

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

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





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






						'''simple docstring'''







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

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

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





					@slow
					def        SCREAMING_SNAKE_CASE							(						self    :  str		):






						'''simple docstring'''







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

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

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





					def        SCREAMING_SNAKE_CASE							(						self    :  Tuple		):






						'''simple docstring'''







						UpperCAmelCase_								=     TFAutoModelWithLMHead.from_pretrained(__lowercase ,					from_pt=__lowercase		)
						self.assertIsInstance(__lowercase ,					__lowercase		)
						self.assertEqual(model.num_parameters() ,					1_44_10		)
						self.assertEqual(model.num_parameters(only_trainable=__lowercase		) ,					1_44_10		)

						UpperCAmelCase_								=     AutoModelWithLMHead.from_pretrained(__lowercase ,					from_tf=__lowercase		)
						self.assertIsInstance(__lowercase ,					__lowercase		)
						self.assertEqual(model.num_parameters() ,					1_44_10		)
						self.assertEqual(model.num_parameters(only_trainable=__lowercase		) ,					1_44_10		)





					def        SCREAMING_SNAKE_CASE							(						self    :  Optional[Any]		):






						'''simple docstring'''







						UpperCAmelCase_								=     TFAutoModelWithLMHead.from_pretrained(__lowercase ,					from_pt=__lowercase		)
						self.assertIsInstance(__lowercase ,					__lowercase		)
						self.assertEqual(model.num_parameters() ,					1_44_10		)
						self.assertEqual(model.num_parameters(only_trainable=__lowercase		) ,					1_44_10		)

						UpperCAmelCase_								=     AutoModelWithLMHead.from_pretrained(__lowercase ,					from_tf=__lowercase		)
						self.assertIsInstance(__lowercase ,					__lowercase		)
						self.assertEqual(model.num_parameters() ,					1_44_10		)
						self.assertEqual(model.num_parameters(only_trainable=__lowercase		) ,					1_44_10		)


