"""simple docstring"""







import unittest

from transformers import AutoTokenizer, FalconConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
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 (
	    FalconForCausalLM,
	    FalconForQuestionAnswering,
	    FalconForSequenceClassification,
	    FalconForTokenClassification,
	    FalconModel,
	)

class 		UpperCamelCase      :



				def __init__(self    :				Optional[Any]     ,  _A    :				Dict     ,  _A    :				int=3     ,  _A    :				Optional[int]=7     ,  _A    :				str=True     ,  _A    :				Dict=True     ,  _A    :				Optional[int]=False     ,  _A    :				Tuple=True     ,  _A    :				Any=99     ,  _A    :				List[str]=32     ,  _A    :				List[Any]=5     ,  _A    :				Optional[Any]=4     ,  _A    :				Any=37     ,  _A    :				Tuple="gelu"     ,  _A    :				Dict=0.1     ,  _A    :				Optional[Any]=0.1     ,  _A    :				Optional[int]=5_12     ,  _A    :				Union[str, Any]=16     ,  _A    :				Optional[Any]=2     ,  _A    :				Union[str, Any]=0.02     ,  _A    :				str=3     ,  _A    :				Optional[Any]=4     ,  _A    :				Dict=None     ,  )   ->     List[Any]:
					__snake_case      :							Dict						=			parent
					__snake_case      :							Dict						=			batch_size
					__snake_case      :							Optional[int]						=			seq_length
					__snake_case      :							Tuple						=			is_training
					__snake_case      :							List[str]						=			use_input_mask
					__snake_case      :							Union[str, Any]						=			use_token_type_ids
					__snake_case      :							Optional[Any]						=			use_labels
					__snake_case      :							str						=			vocab_size
					__snake_case      :							Dict						=			hidden_size
					__snake_case      :							Optional[int]						=			num_hidden_layers
					__snake_case      :							Tuple						=			num_attention_heads
					__snake_case      :							Optional[int]						=			intermediate_size
					__snake_case      :							List[str]						=			hidden_act
					__snake_case      :							Optional[Any]						=			hidden_dropout_prob
					__snake_case      :							Any						=			attention_probs_dropout_prob
					__snake_case      :							Tuple						=			max_position_embeddings
					__snake_case      :							int						=			type_vocab_size
					__snake_case      :							List[Any]						=			type_sequence_label_size
					__snake_case      :							Tuple						=			initializer_range
					__snake_case      :							Tuple						=			num_labels
					__snake_case      :							Dict						=			num_choices
					__snake_case      :							List[Any]						=			scope



				def  _lowercase					(self    :				Optional[Any])   ->     int:
					__snake_case      :							str						=			ids_tensor([self.batch_size, self.seq_length]     ,  self.vocab_size)

					__snake_case      :							Union[str, Any]						=			None
					if self.use_input_mask:
						__snake_case      :							Union[str, Any]						=			random_attention_mask([self.batch_size, self.seq_length])

					__snake_case      :							List[str]						=			None

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

					__snake_case      :							Any						=			self.get_config()

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



				def  _lowercase					(self    :				Optional[Any])   ->     Any:
					return FalconConfig(
					    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     ,  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=_A     ,  initializer_range=self.initializer_range     ,  pad_token_id=1     ,  new_decoder_architecture=_A     ,  )



				def  _lowercase					(self    :				int     ,  _A    :				Optional[Any]     ,  _A    :				List[str]     ,  _A    :				Union[str, Any]     ,  _A    :				List[Any]     ,  _A    :				Dict     ,  _A    :				List[Any]     ,  _A    :				Union[str, Any])   ->     str:
					__snake_case      :							Union[str, Any]						=			FalconModel(config=_A)
					model.to(_A)
					model.eval()
					__snake_case      :							int						=			model(_A     ,  attention_mask=_A)
					__snake_case      :							Optional[int]						=			model(_A)
					self.parent.assertEqual(result.last_hidden_state.shape     ,  (self.batch_size, self.seq_length, self.hidden_size))



				def  _lowercase					(self    :				Optional[Any]     ,  _A    :				List[str]     ,  _A    :				Tuple     ,  _A    :				Dict     ,  _A    :				Any     ,  _A    :				List[str]     ,  _A    :				List[Any]     ,  _A    :				List[Any]     ,  _A    :				Any     ,  _A    :				List[Any]     ,  )   ->     Union[str, Any]:
					__snake_case      :							str						=			True
					__snake_case      :							Optional[int]						=			FalconModel(_A)
					model.to(_A)
					model.eval()
					__snake_case      :							Tuple						=			model(
					    _A     ,  attention_mask=_A     ,  encoder_hidden_states=_A     ,  encoder_attention_mask=_A     ,  )
					__snake_case      :							int						=			model(
					    _A     ,  attention_mask=_A     ,  encoder_hidden_states=_A     ,  )
					__snake_case      :							Union[str, Any]						=			model(_A     ,  attention_mask=_A)
					self.parent.assertEqual(result.last_hidden_state.shape     ,  (self.batch_size, self.seq_length, self.hidden_size))



				def  _lowercase					(self    :				Optional[int]     ,  _A    :				Optional[int]     ,  _A    :				Optional[Any]     ,  _A    :				Dict     ,  _A    :				Union[str, Any]     ,  _A    :				int     ,  _A    :				List[str]     ,  _A    :				str     ,  _A    :				int     ,  _A    :				Optional[int]     ,  )   ->     Optional[Any]:
					__snake_case      :							str						=			FalconForCausalLM(config=_A)
					model.to(_A)
					model.eval()
					__snake_case      :							List[Any]						=			model(_A     ,  attention_mask=_A     ,  labels=_A)
					self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.vocab_size))



				def  _lowercase					(self    :				Dict     ,  _A    :				int     ,  _A    :				List[Any]     ,  _A    :				str     ,  _A    :				Union[str, Any]     ,  _A    :				Optional[int]     ,  _A    :				Any     ,  _A    :				Tuple     ,  _A    :				List[Any]     ,  _A    :				Dict     ,  )   ->     Optional[int]:
					__snake_case      :							str						=			True
					__snake_case      :							Any						=			True
					__snake_case      :							int						=			FalconForCausalLM(config=_A)
					model.to(_A)
					model.eval()

					# first forward pass
					__snake_case      :							int						=			model(
					    _A     ,  attention_mask=_A     ,  encoder_hidden_states=_A     ,  encoder_attention_mask=_A     ,  use_cache=_A     ,  )
					__snake_case      :							List[Any]						=			outputs.past_key_values

					# create hypothetical multiple next token and extent to next_input_ids
					__snake_case      :							Dict						=			ids_tensor((self.batch_size, 3)     ,  config.vocab_size)
					__snake_case      :							Union[str, Any]						=			ids_tensor((self.batch_size, 3)     ,  vocab_size=2)

					# append to next input_ids and
					__snake_case      :							List[str]						=			torch.cat([input_ids, next_tokens]     ,  dim=-1)
					__snake_case      :							str						=			torch.cat([input_mask, next_mask]     ,  dim=-1)

					__snake_case      :							str						=			model(
					    _A     ,  attention_mask=_A     ,  encoder_hidden_states=_A     ,  encoder_attention_mask=_A     ,  output_hidden_states=_A     ,  )['hidden_states'][0]
					__snake_case      :							Optional[Any]						=			model(
					    _A     ,  attention_mask=_A     ,  encoder_hidden_states=_A     ,  encoder_attention_mask=_A     ,  past_key_values=_A     ,  output_hidden_states=_A     ,  )['hidden_states'][0]

					# select random slice
					__snake_case      :							Optional[Any]						=			ids_tensor((1,)     ,  output_from_past.shape[-1]).item()
					__snake_case      :							List[Any]						=			output_from_no_past[:, -3:, random_slice_idx].detach()
					__snake_case      :							Optional[Any]						=			output_from_past[:, :, random_slice_idx].detach()

					self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1])

					# test that outputs are equal for slice
					self.parent.assertTrue(torch.allclose(_A     ,  _A     ,  atol=1E-3))






				def  _lowercase					(self    :				Optional[int])   ->     Optional[int]:
					__snake_case      :							Tuple						=			self.prepare_config_and_inputs()
					(
					    (
					    __snake_case
					)		,    (
					    __snake_case
					)		,    (
					    __snake_case
					)		,    (
					    __snake_case
					)		,    (
					    __snake_case
					)		,    (
					    __snake_case
					)		,    (
					    __snake_case
					)		,    
					)      :							Union[str, Any]						=			config_and_inputs
					__snake_case      :							Any						=			{'input_ids': input_ids, 'attention_mask': input_mask}
					return config, inputs_dict







@require_torch
class 		UpperCamelCase      (   lowercase				,     lowercase				,     lowercase				,     unittest.TestCase						):
				UpperCAmelCase    :				List[str]   =		(
				    (
				        FalconModel,
				        FalconForCausalLM,
				        FalconForSequenceClassification,
				        FalconForTokenClassification,
				        FalconForQuestionAnswering,
				    )
				    if is_torch_available()
				    else ()
				)
				UpperCAmelCase    :				Union[str, Any]   =		(FalconForCausalLM,) if is_torch_available() else ()
				UpperCAmelCase    :				Optional[int]   =		(
				    {
				        """feature-extraction""": FalconModel,
				        """text-classification""": FalconForSequenceClassification,
				        """text-generation""": FalconForCausalLM,
				        """question-answering""": FalconForQuestionAnswering,
				        """token-classification""": FalconForTokenClassification,
				        """zero-shot""": FalconForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				UpperCAmelCase    :				str   =		False
				UpperCAmelCase    :				List[Any]   =		False



				def  _lowercase					(self    :				int)   ->     Union[str, Any]:
					__snake_case      :							Optional[int]						=			FalconModelTester(self)
					__snake_case      :							Union[str, Any]						=			ConfigTester(self     ,  config_class=_A     ,  hidden_size=37)



				def  _lowercase					(self    :				List[str])   ->     Dict:
					self.config_tester.run_common_tests()



				def  _lowercase					(self    :				List[str])   ->     Any:
					__snake_case      :							List[str]						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*_A)



				def  _lowercase					(self    :				Union[str, Any])   ->     Any:
					__snake_case		,    *__snake_case      :							Tuple						=			self.model_tester.prepare_config_and_inputs()
					for alibi in [True, False]:
						__snake_case      :							int						=			alibi
						self.model_tester.create_and_check_model(_A     ,  *_A)



				def  _lowercase					(self    :				Dict)   ->     List[str]:
					__snake_case		,    __snake_case      :							List[Any]						=			self.model_tester.prepare_config_and_inputs_for_common()
					__snake_case      :							List[str]						=			3
					__snake_case      :							Union[str, Any]						=			input_dict['input_ids']
					__snake_case      :							Optional[int]						=			input_ids.ne(1).to(_A)
					__snake_case      :							List[Any]						=			ids_tensor([self.model_tester.batch_size]     ,  self.model_tester.type_sequence_label_size)
					__snake_case      :							Optional[Any]						=			FalconForSequenceClassification(_A)
					model.to(_A)
					model.eval()
					__snake_case      :							Any						=			model(_A     ,  attention_mask=_A     ,  labels=_A)
					self.assertEqual(result.logits.shape     ,  (self.model_tester.batch_size, self.model_tester.num_labels))



				def  _lowercase					(self    :				Any)   ->     Optional[int]:
					__snake_case		,    __snake_case      :							Tuple						=			self.model_tester.prepare_config_and_inputs_for_common()
					__snake_case      :							Optional[Any]						=			3
					__snake_case      :							Optional[Any]						=			'single_label_classification'
					__snake_case      :							Union[str, Any]						=			input_dict['input_ids']
					__snake_case      :							Optional[int]						=			input_ids.ne(1).to(_A)
					__snake_case      :							List[Any]						=			ids_tensor([self.model_tester.batch_size]     ,  self.model_tester.type_sequence_label_size)
					__snake_case      :							Any						=			FalconForSequenceClassification(_A)
					model.to(_A)
					model.eval()
					__snake_case      :							Any						=			model(_A     ,  attention_mask=_A     ,  labels=_A)
					self.assertEqual(result.logits.shape     ,  (self.model_tester.batch_size, self.model_tester.num_labels))



				def  _lowercase					(self    :				Optional[Any])   ->     List[Any]:
					__snake_case		,    __snake_case      :							Dict						=			self.model_tester.prepare_config_and_inputs_for_common()
					__snake_case      :							Tuple						=			input_dict['input_ids']
					__snake_case      :							Optional[Any]						=			FalconForCausalLM(_A)
					model.to(_A)
					model.eval()
					__snake_case      :							Dict						=			model(_A     ,  use_cache=_A)
					__snake_case      :							Optional[Any]						=			input_ids.shape[0]
					__snake_case      :							List[str]						=			model._convert_to_rw_cache(result.past_key_values)
					__snake_case      :							List[str]						=			model._convert_cache_to_standard_format(_A     ,  _A)
					for layer in range(len(_A)):
						for tensor_idx in range(2):
							self.assertTrue(rw_cache[layer][tensor_idx].ndim == 3)
							self.assertTrue(result.past_key_values[layer][tensor_idx].ndim == 4)
							self.assertTrue(
							    torch.all(result.past_key_values[layer][tensor_idx] == standard_cache[layer][tensor_idx]))



				def  _lowercase					(self    :				str)   ->     Optional[Any]:
					__snake_case		,    __snake_case      :							Optional[int]						=			self.model_tester.prepare_config_and_inputs_for_common()
					__snake_case      :							Union[str, Any]						=			3
					__snake_case      :							Optional[int]						=			'multi_label_classification'
					__snake_case      :							List[str]						=			input_dict['input_ids']
					__snake_case      :							List[Any]						=			input_ids.ne(1).to(_A)
					__snake_case      :							int						=			ids_tensor(
					    [self.model_tester.batch_size, config.num_labels]     ,  self.model_tester.type_sequence_label_size).to(torch.float)
					__snake_case      :							List[Any]						=			FalconForSequenceClassification(_A)
					model.to(_A)
					model.eval()
					__snake_case      :							Union[str, Any]						=			model(_A     ,  attention_mask=_A     ,  labels=_A)
					self.assertEqual(result.logits.shape     ,  (self.model_tester.batch_size, self.model_tester.num_labels))






				def  _lowercase					(self    :				int)   ->     str:
					# Falcon can have different numbers of KV-heads than the number of query heads, so we need
					# to override this test to use the right head counts.
					for model_class in self.all_generative_model_classes:
						__snake_case		,    __snake_case      :							Optional[Any]						=			self.model_tester.prepare_config_and_inputs_for_common()

						# If it doesn't support cache, pass the test
						if not hasattr(_A     ,  'use_cache'):
							return

						__snake_case      :							Optional[int]						=			model_class(_A).to(_A)
						if "use_cache" not in inputs:
							__snake_case      :							Union[str, Any]						=			True
						__snake_case      :							Any						=			model(**_A)

						# If "past_key_values" is not returned, pass the test (e.g. RWKV uses a different cache name and format)
						if "past_key_values" not in outputs:
							return

						__snake_case      :							Union[str, Any]						=			(
						    getattr(_A     ,  'decoder_layers'     ,  _A)
						    or getattr(_A     ,  'num_decoder_layers'     ,  _A)
						    or config.num_hidden_layers
						)
						__snake_case      :							Optional[int]						=			getattr(_A     ,  'num_kv_heads'     ,  config.num_attention_heads)
						__snake_case      :							Optional[int]						=			getattr(_A     ,  'd_model'     ,  config.hidden_size)
						__snake_case      :							List[str]						=			embed_dim // num_attention_heads

						__snake_case      :							Any						=			outputs['past_key_values']
						self.assertEqual(len(_A)     ,  _A)

						__snake_case		,    __snake_case      :							str						=			inputs['input_ids'].shape
						for i in range(_A):
							if config.new_decoder_architecture:
								__snake_case      :							int						=			config.num_attention_heads
							elif config.multi_query:
								__snake_case      :							Tuple						=			1
							self.assertEqual(len(past_kv[0])     ,  2)  # K V for the decoder = 2
							self.assertEqual(
							    past_kv[i][0].shape     ,  (batch_size, num_attention_heads, seq_length, per_head_embed_dim))
							self.assertEqual(
							    past_kv[i][1].shape     ,  (batch_size, num_attention_heads, seq_length, per_head_embed_dim))







@require_torch
class 		UpperCamelCase      (   unittest.TestCase						):



				@slow
				def  _lowercase					(self    :				Any)   ->     Union[str, Any]:
					__snake_case      :							Tuple						=			AutoTokenizer.from_pretrained('Rocketknight1/falcon-rw-1b')
					__snake_case      :							Any						=			FalconForCausalLM.from_pretrained('Rocketknight1/falcon-rw-1b')
					model.eval()
					model.to(_A)
					__snake_case      :							Optional[int]						=			tokenizer('My favorite food is'     ,  return_tensors='pt').to(_A)

					__snake_case      :							Dict						=			(
					    'My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday.'
					)

					__snake_case      :							Tuple						=			model.generate(**_A     ,  do_sample=_A     ,  max_new_tokens=19)
					__snake_case      :							Optional[int]						=			tokenizer.batch_decode(_A)[0]

					self.assertEqual(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				Optional[Any])   ->     Any:
					# The big models are way too big for the CI, so we use tiny random models that resemble their
					# architectures but with much smaller and fewer layers
					for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
						__snake_case      :							Any						=			AutoTokenizer.from_pretrained(_A)
						__snake_case      :							Optional[int]						=			FalconForCausalLM.from_pretrained(_A)
						model.eval()
						model.to(_A)
						__snake_case      :							Union[str, Any]						=			tokenizer('My favorite food is'     ,  return_tensors='pt').to(_A)

						# We just test that these run without errors - the models are randomly initialized
						# and so the actual text outputs will be garbage
						model.generate(**_A     ,  do_sample=_A     ,  max_new_tokens=4)
						model.generate(**_A     ,  do_sample=_A     ,  max_new_tokens=4)
						model.generate(**_A     ,  num_beams=2     ,  max_new_tokens=4)






				@slow
				def  _lowercase					(self    :				List[str])   ->     Optional[Any]:
					# The big models are way too big for the CI, so we use tiny random models that resemble their
					# architectures but with much smaller and fewer layers
					with torch.no_grad():
						for repo in [
						    "Rocketknight1/falcon-rw-1b",
						    "Rocketknight1/tiny-random-falcon-7b",
						    "Rocketknight1/tiny-random-falcon-40b",
						]:
							__snake_case      :							List[str]						=			AutoTokenizer.from_pretrained(_A)
							__snake_case      :							int						=			FalconForCausalLM.from_pretrained(_A)
							model.eval()
							model.to(device=_A)
							__snake_case      :							List[str]						=			tokenizer('My favorite food is'     ,  return_tensors='pt').to(_A)

							# Test results are the same with and without cache
							__snake_case      :							str						=			model.generate(**_A     ,  do_sample=_A     ,  max_new_tokens=20     ,  use_cache=_A)
							__snake_case      :							List[str]						=			model.generate(**_A     ,  do_sample=_A     ,  max_new_tokens=20     ,  use_cache=_A)
							self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0)






"""simple docstring"""







from argparse import ArgumentParser, Namespace

from ..utils import logging
from . import BaseTransformersCLICommand
def   __UpperCAmelCase    (   UpperCAmelCase_   :    Namespace  )							->      Union[str, Any]:

	'''simple docstring'''





	return ConvertCommand(
	    args.model_type      ,							args.tf_checkpoint      ,							args.pytorch_dump_output      ,							args.config      ,							args.finetuning_task_name  )


_a					:					str=			"\ntransformers can only be used from the commandline to convert TensorFlow models in PyTorch, In that case, it requires\nTensorFlow to be installed. Please see https://www.tensorflow.org/install/ for installation instructions.\n"

class 		UpperCamelCase      (   lowercase						):



				@staticmethod
				def  _lowercase					(_A    :				ArgumentParser)   ->     Tuple:
					__snake_case      :							Optional[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=_A     ,  required=_A     ,  help='Model\'s type.')
					train_parser.add_argument(
					    '--tf_checkpoint'     ,  type=_A     ,  required=_A     ,  help='TensorFlow checkpoint path or folder.')
					train_parser.add_argument(
					    '--pytorch_dump_output'     ,  type=_A     ,  required=_A     ,  help='Path to the PyTorch saved model output.')
					train_parser.add_argument('--config'     ,  type=_A     ,  default=''     ,  help='Configuration file path or folder.')
					train_parser.add_argument(
					    '--finetuning_task_name'     ,  type=_A     ,  default=_A     ,  help='Optional fine-tuning task name if the TF model was a finetuned model.'     ,  )
					train_parser.set_defaults(func=_A)



				def __init__(self    :				List[str]     ,  _A    :				str     ,  _A    :				str     ,  _A    :				str     ,  _A    :				str     ,  _A    :				str     ,  *_A    :				Any     ,  )   ->     Optional[Any]:
					__snake_case      :							List[Any]						=			logging.get_logger('transformers-cli/converting')

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






				def  _lowercase					(self    :				List[str])   ->     str:
					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(_A)

						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(_A)

						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(_A)

						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(_A)

						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(_A)

						if "ckpt" in self._tf_checkpoint.lower():
							__snake_case      :							Union[str, Any]						=			self._tf_checkpoint
							__snake_case      :							List[Any]						=			''
						else:
							__snake_case      :							Optional[Any]						=			self._tf_checkpoint
							__snake_case      :							List[Any]						=			''
						convert_transfo_xl_checkpoint_to_pytorch(
						    _A     ,  self._config     ,  self._pytorch_dump_output     ,  _A)
					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(_A)

						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(_A)

						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]')





