


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




		'''simple docstring'''







		@slow
		def 							__A						(	self				)     ->							int:
								# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								for model_name in ["bert-base-uncased"]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModel.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModel.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							List[Any]:
								# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								for model_name in ["bert-base-uncased"]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelForPreTraining.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelForPreTraining.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							Dict:
								for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelForCausalLM.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														SCREAMING_SNAKE_CASE							,				SCREAMING_SNAKE_CASE													=					TFAutoModelForCausalLM.from_pretrained(
														    lowerCAmelCase__						,       output_loading_info=lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelForCausalLM.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														SCREAMING_SNAKE_CASE							,				SCREAMING_SNAKE_CASE													=					AutoModelForCausalLM.from_pretrained(
														    lowerCAmelCase__						,       output_loading_info=lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							Optional[int]:
								for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelWithLMHead.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelWithLMHead.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							Optional[int]:
								for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelForMaskedLM.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														SCREAMING_SNAKE_CASE							,				SCREAMING_SNAKE_CASE													=					TFAutoModelForMaskedLM.from_pretrained(
														    lowerCAmelCase__						,       output_loading_info=lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelForMaskedLM.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														SCREAMING_SNAKE_CASE							,				SCREAMING_SNAKE_CASE													=					AutoModelForMaskedLM.from_pretrained(
														    lowerCAmelCase__						,       output_loading_info=lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							int:
								for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelForSeqaSeqLM.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														SCREAMING_SNAKE_CASE							,				SCREAMING_SNAKE_CASE													=					TFAutoModelForSeqaSeqLM.from_pretrained(
														    lowerCAmelCase__						,       output_loading_info=lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelForSeqaSeqLM.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														SCREAMING_SNAKE_CASE							,				SCREAMING_SNAKE_CASE													=					AutoModelForSeqaSeqLM.from_pretrained(
														    lowerCAmelCase__						,       output_loading_info=lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							Any:
								# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								for model_name in ["bert-base-uncased"]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelForSequenceClassification.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelForSequenceClassification.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		@slow
		def 							__A						(	self				)     ->							Any:
								# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								for model_name in ["bert-base-uncased"]:
														SCREAMING_SNAKE_CASE													=					AutoConfig.from_pretrained(lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					TFAutoModelForQuestionAnswering.from_pretrained(lowerCAmelCase__						,       from_pt=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)

														SCREAMING_SNAKE_CASE													=					AutoModelForQuestionAnswering.from_pretrained(lowerCAmelCase__						,       from_tf=lowerCAmelCase__				)
														self.assertIsNotNone(lowerCAmelCase__				)
														self.assertIsInstance(lowerCAmelCase__						,       lowerCAmelCase__				)







		def 							__A						(	self				)     ->							Tuple:
								SCREAMING_SNAKE_CASE													=					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				)

								SCREAMING_SNAKE_CASE													=					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 							__A						(	self				)     ->							Any:
								SCREAMING_SNAKE_CASE													=					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				)

								SCREAMING_SNAKE_CASE													=					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				)






"""simple docstring"""




from __future__ import annotations

from collections.abc import Callable


def     lowercase			(SCREAMING_SNAKE_CASE_		:				Callable[[int | float], int | float] ,			SCREAMING_SNAKE_CASE_		:				int | float ,			SCREAMING_SNAKE_CASE_		:				int | float ,			SCREAMING_SNAKE_CASE_		:				int = 1_00 ,			)   ->						float:
						SCREAMING_SNAKE_CASE													=					x_start
						SCREAMING_SNAKE_CASE													=					fnc(SCREAMING_SNAKE_CASE_  )
						SCREAMING_SNAKE_CASE													=					0.0
						for _ in range(SCREAMING_SNAKE_CASE_  ):
												# Approximates small segments of curve as linear and solve
												# for trapezoidal area
												SCREAMING_SNAKE_CASE													=					(x_end - x_start) / steps + xa
												SCREAMING_SNAKE_CASE													=					fnc(SCREAMING_SNAKE_CASE_  )
												area += abs(fxa + fxa  ) * (xa - xa) / 2
												# Increment step
												SCREAMING_SNAKE_CASE													=					xa
												SCREAMING_SNAKE_CASE													=					fxa
						return area


if __name__ == "__main__":


	def     lowercase			(SCREAMING_SNAKE_CASE_		:				Optional[int]  )   ->						Dict:
							return x**3 + x**2

	print('''f(x) = x^3 + x^2''')
	print('''The area between the curve, x = -5, x = 5 and the x axis is:''')
	__UpperCamelCase						=      10
	while i <= 100000:
		print(f'''with {i} steps: {trapezoidal_area(f, -5, 5, i)}''')
		i *= 10


