






'''simple docstring'''



import unittest

from transformers import MobileBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          MODEL_FOR_PRETRAINING_MAPPING,
          MobileBertForMaskedLM,
          MobileBertForMultipleChoice,
          MobileBertForNextSentencePrediction,
          MobileBertForPreTraining,
          MobileBertForQuestionAnswering,
          MobileBertForSequenceClassification,
          MobileBertForTokenClassification,
          MobileBertModel,
      )
class UpperCAmelCase_       :




      """simple docstring"""




      def __init__(			self      :		List[str]  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Dict=13  ,   UpperCAmelCase      :		Optional[int]=7  ,   UpperCAmelCase      :		str=True  ,   UpperCAmelCase      :		List[Any]=True  ,   UpperCAmelCase      :		Optional[int]=True  ,   UpperCAmelCase      :		Dict=True  ,   UpperCAmelCase      :		str=99  ,   UpperCAmelCase      :		Union[str, Any]=64  ,   UpperCAmelCase      :		List[str]=32  ,   UpperCAmelCase      :		List[str]=5  ,   UpperCAmelCase      :		Dict=4  ,   UpperCAmelCase      :		Any=37  ,   UpperCAmelCase      :		Union[str, Any]="gelu"  ,   UpperCAmelCase      :		Dict=0.1  ,   UpperCAmelCase      :		Tuple=0.1  ,   UpperCAmelCase      :		List[Any]=512  ,   UpperCAmelCase      :		List[str]=16  ,   UpperCAmelCase      :		Any=2  ,   UpperCAmelCase      :		Union[str, Any]=0.0_2  ,   UpperCAmelCase      :		str=3  ,   UpperCAmelCase      :		List[Any]=4  ,   UpperCAmelCase      :		int=None  ,   )	->	Dict:


       '''simple docstring'''

       lowercase       : Dict						=parent
       lowercase       : Optional[Any]						=batch_size
       lowercase       : Union[str, Any]						=seq_length
       lowercase       : Optional[int]						=is_training
       lowercase       : Optional[Any]						=use_input_mask
       lowercase       : int						=use_token_type_ids
       lowercase       : List[Any]						=use_labels
       lowercase       : List[Any]						=vocab_size
       lowercase       : Union[str, Any]						=hidden_size
       lowercase       : Dict						=embedding_size
       lowercase       : Optional[int]						=num_hidden_layers
       lowercase       : List[str]						=num_attention_heads
       lowercase       : List[str]						=intermediate_size
       lowercase       : List[Any]						=hidden_act
       lowercase       : List[str]						=hidden_dropout_prob
       lowercase       : Tuple						=attention_probs_dropout_prob
       lowercase       : str						=max_position_embeddings
       lowercase       : str						=type_vocab_size
       lowercase       : Tuple						=type_sequence_label_size
       lowercase       : str						=initializer_range
       lowercase       : Optional[Any]						=num_labels
       lowercase       : List[Any]						=num_choices
       lowercase       : List[str]						=scope






      def 					A__   (			self      :		Dict		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : Optional[Any]						=ids_tensor([self.batch_size, self.seq_length]  ,   self.vocab_size		)

       lowercase       : List[Any]						=None
       if self.use_input_mask:
        lowercase       : List[Any]						=random_attention_mask([self.batch_size, self.seq_length]		)

       lowercase       : str						=None
       if self.use_token_type_ids:
        lowercase       : List[str]						=ids_tensor([self.batch_size, self.seq_length]  ,   self.type_vocab_size		)

       lowercase       : Tuple						=None
       lowercase       : Optional[int]						=None
       lowercase       : Union[str, Any]						=None
       if self.use_labels:
        lowercase       : str						=ids_tensor([self.batch_size]  ,   self.type_sequence_label_size		)
        lowercase       : Dict						=ids_tensor([self.batch_size, self.seq_length]  ,   self.num_labels		)
        lowercase       : List[Any]						=ids_tensor([self.batch_size]  ,   self.num_choices		)

       lowercase       : Optional[int]						=self.get_config()

       return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels






      def 					A__   (			self      :		List[Any]		)	->	Any:


       '''simple docstring'''

       return MobileBertConfig(
           vocab_size=self.vocab_size  ,   hidden_size=self.hidden_size  ,   num_hidden_layers=self.num_hidden_layers  ,   num_attention_heads=self.num_attention_heads  ,   intermediate_size=self.intermediate_size  ,   embedding_size=self.embedding_size  ,   hidden_act=self.hidden_act  ,   hidden_dropout_prob=self.hidden_dropout_prob  ,   attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,   max_position_embeddings=self.max_position_embeddings  ,   type_vocab_size=self.type_vocab_size  ,   is_decoder=UpperCAmelCase  ,   initializer_range=self.initializer_range  ,   )






      def 					A__   (			self      :		Union[str, Any]  ,   UpperCAmelCase      :		Dict  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		int  ,   UpperCAmelCase      :		Optional[Any]  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		Union[str, Any]		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : int						=MobileBertModel(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : List[Any]						=model(UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase		)
       lowercase       : Optional[int]						=model(UpperCAmelCase  ,   token_type_ids=UpperCAmelCase		)
       lowercase       : List[str]						=model(UpperCAmelCase		)

       self.parent.assertEqual(result.last_hidden_state.shape  ,   (self.batch_size, self.seq_length, self.hidden_size)		)
       self.parent.assertEqual(result.pooler_output.shape  ,   (self.batch_size, self.hidden_size)		)






      def 					A__   (			self      :		Dict  ,   UpperCAmelCase      :		int  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		Union[str, Any]  ,   UpperCAmelCase      :		int  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		Tuple  ,   UpperCAmelCase      :		str		)	->	str:


       '''simple docstring'''

       lowercase       : Optional[int]						=MobileBertForMaskedLM(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Tuple						=model(UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   labels=UpperCAmelCase		)
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, self.seq_length, self.vocab_size)		)






      def 					A__   (			self      :		Dict  ,   UpperCAmelCase      :		Tuple  ,   UpperCAmelCase      :		str  ,   UpperCAmelCase      :		Dict  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		Tuple		)	->	int:


       '''simple docstring'''

       lowercase       : Dict						=MobileBertForNextSentencePrediction(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : List[Any]						=model(
           UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   labels=UpperCAmelCase  ,   )
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, 2)		)






      def 					A__   (			self      :		Union[str, Any]  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		List[str]  ,   UpperCAmelCase      :		Union[str, Any]  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Dict		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : Dict						=MobileBertForPreTraining(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Dict						=model(
           UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   labels=UpperCAmelCase  ,   next_sentence_label=UpperCAmelCase  ,   )
       self.parent.assertEqual(result.prediction_logits.shape  ,   (self.batch_size, self.seq_length, self.vocab_size)		)
       self.parent.assertEqual(result.seq_relationship_logits.shape  ,   (self.batch_size, 2)		)






      def 					A__   (			self      :		Union[str, Any]  ,   UpperCAmelCase      :		List[str]  ,   UpperCAmelCase      :		Dict  ,   UpperCAmelCase      :		Dict  ,   UpperCAmelCase      :		Dict  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		Union[str, Any]		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : str						=MobileBertForQuestionAnswering(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Optional[int]						=model(
           UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   start_positions=UpperCAmelCase  ,   end_positions=UpperCAmelCase  ,   )
       self.parent.assertEqual(result.start_logits.shape  ,   (self.batch_size, self.seq_length)		)
       self.parent.assertEqual(result.end_logits.shape  ,   (self.batch_size, self.seq_length)		)






      def 					A__   (			self      :		List[str]  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		Optional[Any]  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		str  ,   UpperCAmelCase      :		str		)	->	Tuple:


       '''simple docstring'''

       lowercase       : Optional[int]						=self.num_labels
       lowercase       : Tuple						=MobileBertForSequenceClassification(UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Dict						=model(UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   labels=UpperCAmelCase		)
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, self.num_labels)		)






      def 					A__   (			self      :		Dict  ,   UpperCAmelCase      :		List[str]  ,   UpperCAmelCase      :		int  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		int  ,   UpperCAmelCase      :		Any  ,   UpperCAmelCase      :		Union[str, Any]		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : Tuple						=self.num_labels
       lowercase       : Dict						=MobileBertForTokenClassification(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : List[Any]						=model(UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   labels=UpperCAmelCase		)
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, self.seq_length, self.num_labels)		)






      def 					A__   (			self      :		Union[str, Any]  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		Tuple  ,   UpperCAmelCase      :		Optional[int]  ,   UpperCAmelCase      :		int  ,   UpperCAmelCase      :		Optional[Any]  ,   UpperCAmelCase      :		Any		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : List[str]						=self.num_choices
       lowercase       : Dict						=MobileBertForMultipleChoice(config=UpperCAmelCase		)
       model.to(UpperCAmelCase		)
       model.eval()
       lowercase       : Any						=input_ids.unsqueeze(1		).expand(-1  ,   self.num_choices  ,   -1		).contiguous()
       lowercase       : str						=token_type_ids.unsqueeze(1		).expand(-1  ,   self.num_choices  ,   -1		).contiguous()
       lowercase       : Tuple						=input_mask.unsqueeze(1		).expand(-1  ,   self.num_choices  ,   -1		).contiguous()
       lowercase       : Dict						=model(
           UpperCAmelCase  ,   attention_mask=UpperCAmelCase  ,   token_type_ids=UpperCAmelCase  ,   labels=UpperCAmelCase  ,   )
       self.parent.assertEqual(result.logits.shape  ,   (self.batch_size, self.num_choices)		)






      def 					A__   (			self      :		str		)	->	Any:


       '''simple docstring'''

       lowercase       : List[Any]						=self.prepare_config_and_inputs()
       (
           (
           lowercase
       )	,		(
           lowercase
       )	,		(
           lowercase
       )	,		(
           lowercase
       )	,		(
           lowercase
       )	,		(
           lowercase
       )	,		(
           lowercase
       )	,		
       )       : Optional[int]						=config_and_inputs
       lowercase       : Optional[Any]						={'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
       return config, inputs_dict





@require_torch
class UpperCAmelCase_       (     __A					,							__A					,							unittest.TestCase					):




      """simple docstring"""




      UpperCamelCase_             =      (
          (
              MobileBertModel,
              MobileBertForMaskedLM,
              MobileBertForMultipleChoice,
              MobileBertForNextSentencePrediction,
              MobileBertForPreTraining,
              MobileBertForQuestionAnswering,
              MobileBertForSequenceClassification,
              MobileBertForTokenClassification,
          )
          if is_torch_available()
          else ()
      )
      UpperCamelCase_             =      (
          {
              '''feature-extraction''': MobileBertModel,
              '''fill-mask''': MobileBertForMaskedLM,
              '''question-answering''': MobileBertForQuestionAnswering,
              '''text-classification''': MobileBertForSequenceClassification,
              '''token-classification''': MobileBertForTokenClassification,
              '''zero-shot''': MobileBertForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )
      UpperCamelCase_             =      True






      def 					A__   (			self      :		Tuple  ,   UpperCAmelCase      :		List[Any]  ,   UpperCAmelCase      :		str  ,   UpperCAmelCase      :		str=False		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : Dict						=super()._prepare_for_class(UpperCAmelCase  ,   UpperCAmelCase  ,   return_labels=UpperCAmelCase		)

       if return_labels:
        if model_class in get_values(UpperCAmelCase		):
         lowercase       : Any						=torch.zeros(
             (self.model_tester.batch_size, self.model_tester.seq_length)  ,   dtype=torch.long  ,   device=UpperCAmelCase		)
         lowercase       : Optional[int]						=torch.zeros(
             self.model_tester.batch_size  ,   dtype=torch.long  ,   device=UpperCAmelCase		)
       return inputs_dict






      def 					A__   (			self      :		int		)	->	Dict:


       '''simple docstring'''

       lowercase       : List[Any]						=MobileBertModelTester(self		)
       lowercase       : Union[str, Any]						=ConfigTester(self  ,   config_class=UpperCAmelCase  ,   hidden_size=37		)






      def 					A__   (			self      :		str		)	->	List[Any]:


       '''simple docstring'''

       self.config_tester.run_common_tests()






      def 					A__   (			self      :		Tuple		)	->	List[str]:


       '''simple docstring'''

       lowercase       : Optional[Any]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_model(*UpperCAmelCase		)






      def 					A__   (			self      :		int		)	->	Optional[int]:


       '''simple docstring'''

       lowercase       : Tuple						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_masked_lm(*UpperCAmelCase		)






      def 					A__   (			self      :		Union[str, Any]		)	->	Tuple:


       '''simple docstring'''

       lowercase       : Optional[int]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_multiple_choice(*UpperCAmelCase		)






      def 					A__   (			self      :		int		)	->	int:


       '''simple docstring'''

       lowercase       : List[Any]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_next_sequence_prediction(*UpperCAmelCase		)






      def 					A__   (			self      :		Any		)	->	Dict:


       '''simple docstring'''

       lowercase       : Optional[Any]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_pretraining(*UpperCAmelCase		)






      def 					A__   (			self      :		Any		)	->	Any:


       '''simple docstring'''

       lowercase       : List[Any]						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_question_answering(*UpperCAmelCase		)






      def 					A__   (			self      :		Dict		)	->	Optional[Any]:


       '''simple docstring'''

       lowercase       : str						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_sequence_classification(*UpperCAmelCase		)






      def 					A__   (			self      :		Tuple		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : Any						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mobilebert_for_token_classification(*UpperCAmelCase		)





def 				lowercase_					(     __A			:							Any      )							->   List[str]:



 """simple docstring"""




 return torch.tensor(
     __A       ,   dtype=torch.long       ,   device=__A       ,   )


SCREAMING_SNAKE_CASE							=						1E-3





@require_torch
@require_sentencepiece
@require_tokenizers
class UpperCAmelCase_       (     unittest.TestCase					):




      """simple docstring"""




      @slow
      def 					A__   (			self      :		Dict		)	->	Union[str, Any]:


       '''simple docstring'''

       lowercase       : Union[str, Any]						=MobileBertModel.from_pretrained('''google/mobilebert-uncased'''		).to(UpperCAmelCase		)
       lowercase       : Tuple						=_long_tensor([[101, 7110, 1005, 1056, 2023, 1_1333, 1_7413, 1029, 102]]		)
       with torch.no_grad():
        lowercase       : Union[str, Any]						=model(UpperCAmelCase		)[0]
       lowercase       : Optional[int]						=torch.Size((1, 9, 512)		)
       self.assertEqual(output.shape  ,   UpperCAmelCase		)
       lowercase       : Any						=torch.tensor(
           [
               [
                   [-2.4_736_526e07, 8.2_691_656e04, 1.6_521_838e05],
                   [-5.7_541_704e-01, 3.9_056_022e00, 4.4_011_507e00],
                   [2.6_047_359e00, 1.5_677_652e00, -1.7_324_188e-01],
               ]
           ]  ,   device=UpperCAmelCase  ,   )

       # MobileBERT results range from 10e0 to 10e8. Even a 0.0000001% difference with a value of 10e8 results in a
       # ~1 difference, it's therefore not a good idea to measure using addition.
       # Here, we instead divide the expected result with the result in order to obtain ~1. We then check that the
       # result is held between bounds: 1 - TOLERANCE < expected_result / result < 1 + TOLERANCE
       lowercase       : int						=torch.all((expected_slice / output[..., :3, :3]) >= 1 - TOLERANCE		)
       lowercase       : Union[str, Any]						=torch.all((expected_slice / output[..., :3, :3]) <= 1 + TOLERANCE		)

       self.assertTrue(lower_bound and upper_bound		)











"""simple docstring"""
from argparse import ArgumentParser, Namespace

from ..utils import logging
from . import BaseTransformersCLICommand

def 							snake_case (  A__		):
			return ConvertCommand(
			    args.model_type      ,args.tf_checkpoint      ,args.pytorch_dump_output      ,args.config      ,args.finetuning_task_name		)


lowerCamelCase_							      = '''
transformers can only be used from the commandline to convert TensorFlow models in PyTorch, In that case, it requires
TensorFlow to be installed. Please see https://www.tensorflow.org/install/ for installation instructions.
'''







class      UpperCamelCase_			(__A	):





	@staticmethod
	def 	_SCREAMING_SNAKE_CASE ( lowerCAmelCase_   :					ArgumentParser		)		->     Optional[Any]:
				UpperCAmelCase_	:					Any     	=   parser.add_parser(
				    "convert"      ,      help="CLI tool to run convert model from original author checkpoints to Transformers PyTorch checkpoints."      ,      )
				train_parser.add_argument("--model_type"      ,      type=lowerCAmelCase_      ,      required=lowerCAmelCase_      ,      help="Model's type."		)
				train_parser.add_argument(
				    "--tf_checkpoint"      ,      type=lowerCAmelCase_      ,      required=lowerCAmelCase_      ,      help="TensorFlow checkpoint path or folder."		)
				train_parser.add_argument(
				    "--pytorch_dump_output"      ,      type=lowerCAmelCase_      ,      required=lowerCAmelCase_      ,      help="Path to the PyTorch saved model output."		)
				train_parser.add_argument("--config"      ,      type=lowerCAmelCase_      ,      default=""      ,      help="Configuration file path or folder."		)
				train_parser.add_argument(
				    "--finetuning_task_name"      ,      type=lowerCAmelCase_      ,      default=lowerCAmelCase_      ,      help="Optional fine-tuning task name if the TF model was a finetuned model."      ,      )
				train_parser.set_defaults(func=lowerCAmelCase_		)





	def __init__( self   :					str      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					str      ,      *lowerCAmelCase_   :					Tuple      ,      )		->     int:
				UpperCAmelCase_	:					Dict     	=   logging.get_logger("transformers-cli/converting"		)

				self._logger.info(f"""Loading model {model_type}"""		)
				UpperCAmelCase_	:					Optional[int]     	=   model_type
				UpperCAmelCase_	:					Union[str, Any]     	=   tf_checkpoint
				UpperCAmelCase_	:					Tuple     	=   pytorch_dump_output
				UpperCAmelCase_	:					Tuple     	=   config
				UpperCAmelCase_	:					List[str]     	=   finetuning_task_name





	def 	_SCREAMING_SNAKE_CASE ( self   :					Tuple		)		->     List[Any]:
				if self._model_type == "albert":
							try:
										from ..models.albert.convert_albert_original_tf_checkpoint_to_pytorch import (
										    convert_tf_checkpoint_to_pytorch,
										)
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							convert_tf_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				elif self._model_type == "bert":
							try:
										from ..models.bert.convert_bert_original_tf_checkpoint_to_pytorch import (
										    convert_tf_checkpoint_to_pytorch,
										)
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							convert_tf_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				elif self._model_type == "funnel":
							try:
										from ..models.funnel.convert_funnel_original_tf_checkpoint_to_pytorch import (
										    convert_tf_checkpoint_to_pytorch,
										)
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							convert_tf_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				elif self._model_type == "t5":
							try:
										from ..models.ta.convert_ta_original_tf_checkpoint_to_pytorch import convert_tf_checkpoint_to_pytorch
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							convert_tf_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				elif self._model_type == "gpt":
							from ..models.openai.convert_openai_original_tf_checkpoint_to_pytorch import (
							    convert_openai_checkpoint_to_pytorch,
							)

							convert_openai_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				elif self._model_type == "transfo_xl":
							try:
										from ..models.transfo_xl.convert_transfo_xl_original_tf_checkpoint_to_pytorch import (
										    convert_transfo_xl_checkpoint_to_pytorch,
										)
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							if "ckpt" in self._tf_checkpoint.lower():
										UpperCAmelCase_	:					Union[str, Any]     	=   self._tf_checkpoint
										UpperCAmelCase_	:					List[str]     	=   ""
							else:
										UpperCAmelCase_	:					Any     	=   self._tf_checkpoint
										UpperCAmelCase_	:					Any     	=   ""
							convert_transfo_xl_checkpoint_to_pytorch(
							    lowerCAmelCase_      ,      self._config      ,      self._pytorch_dump_output      ,      lowerCAmelCase_		)
				elif self._model_type == "gpt2":
							try:
										from ..models.gpta.convert_gpta_original_tf_checkpoint_to_pytorch import (
										    convert_gpta_checkpoint_to_pytorch,
										)
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							convert_gpta_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				elif self._model_type == "xlnet":
							try:
										from ..models.xlnet.convert_xlnet_original_tf_checkpoint_to_pytorch import (
										    convert_xlnet_checkpoint_to_pytorch,
										)
							except ImportError:
										raise ImportError(lowerCAmelCase_		)

							convert_xlnet_checkpoint_to_pytorch(
							    self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output      ,      self._finetuning_task_name		)
				elif self._model_type == "xlm":
							from ..models.xlm.convert_xlm_original_pytorch_checkpoint_to_pytorch import (
							    convert_xlm_checkpoint_to_pytorch,
							)

							convert_xlm_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._pytorch_dump_output		)
				elif self._model_type == "lxmert":
							from ..models.lxmert.convert_lxmert_original_tf_checkpoint_to_pytorch import (
							    convert_lxmert_checkpoint_to_pytorch,
							)

							convert_lxmert_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._pytorch_dump_output		)
				elif self._model_type == "rembert":
							from ..models.rembert.convert_rembert_tf_checkpoint_to_pytorch import (
							    convert_rembert_tf_checkpoint_to_pytorch,
							)

							convert_rembert_tf_checkpoint_to_pytorch(self._tf_checkpoint      ,      self._config      ,      self._pytorch_dump_output		)
				else:
							raise ValueError(
							    "--model_type should be selected in the list [bert, gpt, gpt2, t5, transfo_xl, xlnet, xlm, lxmert]"		)



