






import re
import time
from typing import Optional

import IPython.display as disp

from ..trainer_callback import TrainerCallback
from ..trainer_utils import IntervalStrategy, has_length






def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    str:
							_lowercase							:   Any 							=   int(_SCREAMING_SNAKE_CASE				)
							_lowercase							,							_lowercase							,							_lowercase							:   str 							=   t // 3_600, (t // 60) % 60, t % 60
							return F"""{h}:{m:02d}:{s:02d}""" if h != 0 else F"""{m:02d}:{s:02d}"""






def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE=300				)     ->    Union[str, Any]:
							return F"""
    <div>
      {prefix}
      <progress value='{value}' max='{total}' style='width:{width}px; height:20px; vertical-align: middle;'></progress>
      {label}
    </div>
    """






def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    int:
							_lowercase							:   str 							=   '<table border="1" class="dataframe">\n'
							html_code += """  <thead>\n <tr style="text-align: left;">\n"""
							for i in items[0]:
														html_code += F"""      <th>{i}</th>\n"""
							html_code += "    </tr>\n  </thead>\n  <tbody>\n"
							for line in items[1:]:
														html_code += "    <tr>\n"
														for elt in line:
																					_lowercase							:   List[Any] 							=   F"""{elt:.6f}""" if isinstance(_SCREAMING_SNAKE_CASE     ,     _SCREAMING_SNAKE_CASE				) else str(_SCREAMING_SNAKE_CASE				)
																					html_code += F"""      <td>{elt}</td>\n"""
														html_code += "    </tr>\n"
							html_code += "  </tbody>\n</table><p>"
							return html_code

class 				lowerCAmelCase_	:
				_UpperCamelCase					:       List[str]							       = 5
				_UpperCamelCase					:       Optional[int]							       = 0.2


				def __init__(					self ,						_lowerCAmelCase ,						_lowerCAmelCase = None ,						_lowerCAmelCase = True ,						_lowerCAmelCase = None ,						_lowerCAmelCase = 3_0_0 ,						):
											_lowercase							:   List[Any] 							=   total
											_lowercase							:   List[Any] 							=   '' if prefix is None else prefix
											_lowercase							:   Tuple 							=   leave
											_lowercase							:   Dict 							=   parent
											_lowercase							:   Union[str, Any] 							=   width
											_lowercase							:   str 							=   None
											_lowercase							:   Dict 							=   None
											_lowercase							:   Optional[int] 							=   None


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase = False ,						_lowerCAmelCase = None      ):
											_lowercase							:   str 							=   value
											if comment is not None:
																		_lowercase							:   List[Any] 							=   comment
											if self.last_value is None:
																		_lowercase							:   Optional[Any] 							=   time.time()
																		_lowercase							:   List[Any] 							=   value
																		_lowercase							:   List[Any] 							=   None
																		_lowercase							:   Union[str, Any] 							=   self.warmup
																		_lowercase							:   Union[str, Any] 							=   1
																		self.update_bar(lowerCAmelCase_      )
											elif value <= self.last_value and not force_update:
																		return
											elif force_update or self.first_calls > 0 or value >= min(self.last_value + self.wait_for ,						self.total      ):
																		if self.first_calls > 0:
																									self.first_calls -= 1
																		_lowercase							:   Union[str, Any] 							=   time.time()
																		_lowercase							:   Union[str, Any] 							=   current_time - self.start_time
																		# We could have value = self.start_value if the update is called twixe with the same start value.
																		if value > self.start_value:
																									_lowercase							:   str 							=   self.elapsed_time / (value - self.start_value)
																		else:
																									_lowercase							:   Optional[int] 							=   None
																		if value >= self.total:
																									_lowercase							:   Dict 							=   self.total
																									_lowercase							:   Optional[Any] 							=   None
																									if not self.leave:
																																self.close()
																		elif self.average_time_per_item is not None:
																									_lowercase							:   List[Any] 							=   self.average_time_per_item * (self.total - value)
																		self.update_bar(lowerCAmelCase_      )
																		_lowercase							:   List[Any] 							=   value
																		_lowercase							:   List[str] 							=   current_time
																		if self.average_time_per_item is None:
																									_lowercase							:   Union[str, Any] 							=   1
																		else:
																									_lowercase							:   List[Any] 							=   max(int(self.update_every / self.average_time_per_item      ) ,						1      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase=None      ):
											_lowercase							:   List[str] 							=   ' ' * (len(str(self.total      )      ) - len(str(lowerCAmelCase_      )      )) + str(lowerCAmelCase_      )
											if self.elapsed_time is None:
																		_lowercase							:   Optional[Any] 							=   F"""[{spaced_value}/{self.total} : < :"""
											elif self.predicted_remaining is None:
																		_lowercase							:   List[str] 							=   F"""[{spaced_value}/{self.total} {format_time(self.elapsed_time      )}"""
											else:
																		_lowercase							:   Dict 							=   (
																		    F"""[{spaced_value}/{self.total} {format_time(self.elapsed_time      )} <"""
																		    F""" {format_time(self.predicted_remaining      )}"""
																		)
																		self.label += F""", {1/self.average_time_per_item:.2f} it/s"""
											self.label += "]" if self.comment is None or len(self.comment      ) == 0 else F""", {self.comment}]"""
											self.display()


				def 						__a					(					self      ):
											_lowercase							:   Tuple 							=   html_progress_bar(self.value ,						self.total ,						self.prefix ,						self.label ,						self.width      )
											if self.parent is not None:
																		# If this is a child bar, the parent will take care of the display.
																		self.parent.display()
																		return
											if self.output is None:
																		_lowercase							:   int 							=   disp.display(disp.HTML(self.html_code      ) ,						display_id=lowerCAmelCase_      )
											else:
																		self.output.update(disp.HTML(self.html_code      )      )


				def 						__a					(					self      ):
											if self.parent is None and self.output is not None:
																		self.output.update(disp.HTML(''      )      )




class 				lowerCAmelCase_	(		a_			):


				def __init__(					self ,						_lowerCAmelCase ,						_lowerCAmelCase=None      ):
											super().__init__(lowerCAmelCase_      )
											_lowercase							:   Tuple 							=   None if column_names is None else [column_names]
											_lowercase							:   Tuple 							=   None


				def 						__a					(					self      ):
											_lowercase							:   str 							=   html_progress_bar(self.value ,						self.total ,						self.prefix ,						self.label ,						self.width      )
											if self.inner_table is not None:
																		self.html_code += text_to_html_table(self.inner_table      )
											if self.child_bar is not None:
																		self.html_code += self.child_bar.html_code
											if self.output is None:
																		_lowercase							:   int 							=   disp.display(disp.HTML(self.html_code      ) ,						display_id=lowerCAmelCase_      )
											else:
																		self.output.update(disp.HTML(self.html_code      )      )


				def 						__a					(					self ,						_lowerCAmelCase      ):
											if self.inner_table is None:
																		_lowercase							:   Tuple 							=   [list(values.keys()      ), list(values.values()      )]
											else:
																		_lowercase							:   List[str] 							=   self.inner_table[0]
																		if len(self.inner_table      ) == 1:
																									# We give a chance to update the column names at the first iteration
																									for key in values.keys():
																																if key not in columns:
																																							columns.append(lowerCAmelCase_      )
																									_lowercase							:   Tuple 							=   columns
																		self.inner_table.append([values[c] for c in columns]      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase=None ,						_lowerCAmelCase=3_0_0      ):
											_lowercase							:   Tuple 							=   NotebookProgressBar(lowerCAmelCase_ ,						prefix=lowerCAmelCase_ ,						parent=self ,						width=lowerCAmelCase_      )
											return self.child_bar


				def 						__a					(					self      ):
											_lowercase							:   Optional[Any] 							=   None
											self.display()




class 				lowerCAmelCase_	(		a_			):


				def __init__(					self      ):
											_lowercase							:   Optional[Any] 							=   None
											_lowercase							:   Dict 							=   None
											_lowercase							:   Optional[int] 							=   False


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						**_lowerCAmelCase      ):
											_lowercase							:   Tuple 							=   'Epoch' if args.evaluation_strategy == IntervalStrategy.EPOCH else 'Step'
											_lowercase							:   int 							=   0
											_lowercase							:   Optional[int] 							=   0
											_lowercase							:   str 							=   [self.first_column] + ['Training Loss']
											if args.evaluation_strategy != IntervalStrategy.NO:
																		column_names.append('Validation Loss'      )
											_lowercase							:   Tuple 							=   NotebookTrainingTracker(state.max_steps ,						lowerCAmelCase_      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						**_lowerCAmelCase      ):
											_lowercase							:   List[Any] 							=   int(state.epoch      ) if int(state.epoch      ) == state.epoch else F"""{state.epoch:.2f}"""
											self.training_tracker.update(
											    state.global_step + 1 ,						comment=F"""Epoch {epoch}/{state.num_train_epochs}""" ,						force_update=self._force_next_update ,						)
											_lowercase							:   Tuple 							=   False


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase=None ,						**_lowerCAmelCase      ):
											if not has_length(lowerCAmelCase_      ):
																		return
											if self.prediction_bar is None:
																		if self.training_tracker is not None:
																									_lowercase							:   Optional[int] 							=   self.training_tracker.add_child(len(lowerCAmelCase_      )      )
																		else:
																									_lowercase							:   Any 							=   NotebookProgressBar(len(lowerCAmelCase_      )      )
																		self.prediction_bar.update(1      )
											else:
																		self.prediction_bar.update(self.prediction_bar.value + 1      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						**_lowerCAmelCase      ):
											if self.prediction_bar is not None:
																		self.prediction_bar.close()
											_lowercase							:   Any 							=   None


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase=None ,						**_lowerCAmelCase      ):
											# Only for when there is no evaluation
											if args.evaluation_strategy == IntervalStrategy.NO and "loss" in logs:
																		_lowercase							:   List[Any] 							=   {'Training Loss': logs['loss']}
																		# First column is necessarily Step sine we're not in epoch eval strategy
																		_lowercase							:   int 							=   state.global_step
																		self.training_tracker.write_line(lowerCAmelCase_      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase=None ,						**_lowerCAmelCase      ):
											if self.training_tracker is not None:
																		_lowercase							:   str 							=   {'Training Loss': 'No log', 'Validation Loss': 'No log'}
																		for log in reversed(state.log_history      ):
																									if "loss" in log:
																																_lowercase							:   Optional[int] 							=   log['loss']
																																break

																		if self.first_column == "Epoch":
																									_lowercase							:   Optional[Any] 							=   int(state.epoch      )
																		else:
																									_lowercase							:   List[Any] 							=   state.global_step
																		_lowercase							:   Tuple 							=   'eval'
																		for k in metrics:
																									if k.endswith('_loss'      ):
																																_lowercase							:   List[str] 							=   re.sub(r'\_loss$' ,						'' ,						lowerCAmelCase_      )
																		_lowercase							:   str 							=   metrics.pop('total_flos' ,						lowerCAmelCase_      )
																		_lowercase							:   Tuple 							=   metrics.pop('epoch' ,						lowerCAmelCase_      )
																		_lowercase							:   int 							=   metrics.pop(F"""{metric_key_prefix}_runtime""" ,						lowerCAmelCase_      )
																		_lowercase							:   List[Any] 							=   metrics.pop(F"""{metric_key_prefix}_samples_per_second""" ,						lowerCAmelCase_      )
																		_lowercase							:   Union[str, Any] 							=   metrics.pop(F"""{metric_key_prefix}_steps_per_second""" ,						lowerCAmelCase_      )
																		_lowercase							:   Optional[int] 							=   metrics.pop(F"""{metric_key_prefix}_jit_compilation_time""" ,						lowerCAmelCase_      )
																		for k, v in metrics.items():
																									if k == F"""{metric_key_prefix}_loss""":
																																_lowercase							:   Tuple 							=   v
																									else:
																																_lowercase							:   Tuple 							=   k.split('_'      )
																																_lowercase							:   List[str] 							=   ' '.join([part.capitalize() for part in splits[1:]]      )
																																_lowercase							:   int 							=   v
																		self.training_tracker.write_line(lowerCAmelCase_      )
																		self.training_tracker.remove_child()
																		_lowercase							:   Any 							=   None
																		# Evaluation takes a long time so we should force the next update.
																		_lowercase							:   Any 							=   True


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						**_lowerCAmelCase      ):
											self.training_tracker.update(
											    state.global_step ,						comment=F"""Epoch {int(state.epoch      )}/{state.num_train_epochs}""" ,						force_update=lowerCAmelCase_      )
											_lowercase							:   Any 							=   None








'''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 					lowerCAmelCase     (  self							:			List[str]	)      ->		List[Any]:
						# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						for model_name in ["bert-base-uncased"]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModel.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModel.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			Tuple	)      ->		Optional[Any]:
						# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						for model_name in ["bert-base-uncased"]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelForPreTraining.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelForPreTraining.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			int	)      ->		Optional[int]:
						for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelForCausalLM.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									__A,	__A=	TFAutoModelForCausalLM.from_pretrained(
									    lowerCAmelCase_			,    output_loading_info=lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelForCausalLM.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									__A,	__A=	AutoModelForCausalLM.from_pretrained(
									    lowerCAmelCase_			,    output_loading_info=lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		Optional[Any]:
						for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelWithLMHead.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelWithLMHead.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		Optional[int]:
						for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelForMaskedLM.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									__A,	__A=	TFAutoModelForMaskedLM.from_pretrained(
									    lowerCAmelCase_			,    output_loading_info=lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelForMaskedLM.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									__A,	__A=	AutoModelForMaskedLM.from_pretrained(
									    lowerCAmelCase_			,    output_loading_info=lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			Tuple	)      ->		Dict:
						for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelForSeqaSeqLM.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									__A,	__A=	TFAutoModelForSeqaSeqLM.from_pretrained(
									    lowerCAmelCase_			,    output_loading_info=lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelForSeqaSeqLM.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									__A,	__A=	AutoModelForSeqaSeqLM.from_pretrained(
									    lowerCAmelCase_			,    output_loading_info=lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			Optional[Any]	)      ->		str:
						# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						for model_name in ["bert-base-uncased"]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelForSequenceClassification.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelForSequenceClassification.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			@slow
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		List[Any]:
						# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						for model_name in ["bert-base-uncased"]:
									__A=	AutoConfig.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	TFAutoModelForQuestionAnswering.from_pretrained(lowerCAmelCase_			,    from_pt=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)

									__A=	AutoModelForQuestionAnswering.from_pretrained(lowerCAmelCase_			,    from_tf=lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)
									self.assertIsInstance(lowerCAmelCase_			,    lowerCAmelCase_	)
			def 					lowerCAmelCase     (  self							:			int	)      ->		List[str]:
						__A=	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	)

						__A=	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 					lowerCAmelCase     (  self							:			Optional[Any]	)      ->		Tuple:
						__A=	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	)

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



