"""simple docstring"""







from manim import *

class 		UpperCamelCase      (   lowercase						):



				def  _lowercase					(self    :				Union[str, Any])   ->     Tuple:
					__snake_case      :							Tuple						=			Rectangle(height=0.5     ,  width=0.5)
					__snake_case      :							str						=			Rectangle(height=0.46     ,  width=0.46).set_stroke(width=0)

					__snake_case      :							Optional[Any]						=			[mem.copy() for i in range(6)]
					__snake_case      :							int						=			[mem.copy() for i in range(6)]
					__snake_case      :							Optional[Any]						=			VGroup(*_A).arrange(_A     ,  buff=0)
					__snake_case      :							Optional[Any]						=			VGroup(*_A).arrange(_A     ,  buff=0)
					__snake_case      :							List[str]						=			VGroup(_A     ,  _A).arrange(_A     ,  buff=0)
					__snake_case      :							Optional[Any]						=			Text('CPU'     ,  font_size=24)
					__snake_case      :							Optional[int]						=			Group(_A     ,  _A).arrange(_A     ,  buff=0.5     ,  aligned_edge=_A)
					cpu.move_to([-2.5, -0.5, 0])
					self.add(_A)

					__snake_case      :							List[Any]						=			[mem.copy() for i in range(4)]
					__snake_case      :							List[str]						=			VGroup(*_A).arrange(_A     ,  buff=0)
					__snake_case      :							Dict						=			Text('GPU'     ,  font_size=24)
					__snake_case      :							int						=			Group(_A     ,  _A).arrange(_A     ,  buff=0.5     ,  aligned_edge=_A)
					gpu.move_to([-1, -1, 0])
					self.add(_A)

					__snake_case      :							int						=			[mem.copy() for i in range(6)]
					__snake_case      :							Union[str, Any]						=			VGroup(*_A).arrange(_A     ,  buff=0)

					__snake_case      :							int						=			Text('Model'     ,  font_size=24)
					__snake_case      :							str						=			Group(_A     ,  _A).arrange(_A     ,  buff=0.5     ,  aligned_edge=_A)
					model.move_to([3, -1.0, 0])
					self.add(_A)

					__snake_case      :							Optional[Any]						=			[]
					for i, rect in enumerate(_A):
						rect.set_stroke(_A)
						# target = fill.copy().set_fill(YELLOW, opacity=0.7)
						# target.move_to(rect)
						# self.add(target)

						__snake_case      :							Dict						=			Rectangle(height=0.46 / 4     ,  width=0.46 / 3).set_stroke(width=0.0).set_fill(_A     ,  opacity=0.7)

						if i == 0:
							cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT)     ,  buff=0.02     ,  direction=_A)
							cpu_target.set_x(cpu_target.get_x() + 0.1)
						elif i == 3:
							cpu_target.next_to(cpu_targs[0]     ,  direction=_A     ,  buff=0.0)
						else:
							cpu_target.next_to(cpu_targs[i - 1]     ,  direction=_A     ,  buff=0.0)
						self.add(_A)
						cpu_targs.append(_A)

					__snake_case      :							Dict						=			[mem.copy() for i in range(6)]
					__snake_case      :							Dict						=			VGroup(*_A).arrange(_A     ,  buff=0)

					__snake_case      :							Any						=			Text('Loaded Checkpoint'     ,  font_size=24)
					__snake_case      :							Tuple						=			Group(_A     ,  _A).arrange(_A     ,  aligned_edge=_A     ,  buff=0.4)
					checkpoint.move_to([3, 0.5, 0])

					__snake_case      :							List[Any]						=			Square(side_length=2.2)
					key.move_to([-5, 2, 0])

					__snake_case      :							List[Any]						=			MarkupText(
					    f"<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model"     ,  font_size=18     ,  )

					key_text.move_to([-5, 2.4, 0])

					self.add(_A     ,  _A)

					__snake_case      :							str						=			MarkupText(
					    f"<span fgcolor='{BLUE}'>●</span> Checkpoint"     ,  font_size=18     ,  )

					blue_text.next_to(_A     ,  DOWN * 2.4     ,  aligned_edge=key_text.get_left())

					__snake_case      :							List[str]						=			MarkupText(
					    f"Next, a <i><span fgcolor=\"{BLUE}\">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor=\"{BLUE}\">single shard</span>."     ,  font_size=24     ,  )
					step_a.move_to([2, 2, 0])
					self.play(Write(_A)     ,  Write(_A))

					self.play(Write(_A     ,  run_time=1)     ,  Create(_A     ,  run_time=1))

					__snake_case      :							Union[str, Any]						=			[]
					__snake_case      :							Dict						=			[]
					for i, rect in enumerate(_A):
						__snake_case      :							Any						=			fill.copy().set_fill(_A     ,  opacity=0.7)
						target.move_to(_A)
						first_animations.append(GrowFromCenter(_A     ,  run_time=1))

						__snake_case      :							Any						=			target.copy()
						cpu_target.generate_target()
						if i < 5:
							cpu_target.target.move_to(cpu_left_col_base[i + 1])
						else:
							cpu_target.target.move_to(cpu_right_col_base[i - 5])
						second_animations.append(MoveToTarget(_A     ,  run_time=1.5))

					self.play(*_A)
					self.play(*_A)
					self.wait()






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





