






"""simple docstring"""






from manim import *




class 							lowerCAmelCase__				(			UpperCAmelCase__ ):






      '''simple docstring'''

      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[str]    						=		Rectangle(height=0.5						,	width=0.5)
          SCREAMING_SNAKE_CASE_      :  Dict    						=		Rectangle(height=0.46						,	width=0.46).set_stroke(width=0)

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

          SCREAMING_SNAKE_CASE_      :  List[str]    						=		[mem.copy() for i in range(1)]
          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		VGroup(*lowercase_).arrange(lowercase_						,	buff=0)
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		Text('''GPU'''						,	font_size=24)
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		Group(lowercase_						,	lowercase_).arrange(lowercase_						,	buff=0.5						,	aligned_edge=lowercase_)
          gpu.align_to(lowercase_						,	lowercase_)
          gpu.set_x(gpu.get_x() - 1)

          self.add(lowercase_)

          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		[mem.copy() for i in range(6)]
          SCREAMING_SNAKE_CASE_      :  Tuple    						=		VGroup(*lowercase_).arrange(lowercase_						,	buff=0)

          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		Text('''Model'''						,	font_size=24)
          SCREAMING_SNAKE_CASE_      :  Tuple    						=		Group(lowercase_						,	lowercase_).arrange(lowercase_						,	buff=0.5						,	aligned_edge=lowercase_)
          model.move_to([3, -1.0, 0])

          self.play(
              Create(lowercase_						,	run_time=1)						,	Create(lowercase_						,	run_time=1)						,	Create(lowercase_						,	run_time=1)						,	)

          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		MarkupText(
              F'First, an empty model skeleton is loaded\ninto <span fgcolor=\'{YELLOW}\'>memory</span> without using much RAM.'						,	font_size=24						,	)

          SCREAMING_SNAKE_CASE_      :  Dict    						=		Square(side_length=2.2)
          key.move_to([-5, 2, 0])

          SCREAMING_SNAKE_CASE_      :  Union[str, 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])

          step_a.move_to([2, 2, 0])
          self.play(Write(lowercase_						,	run_time=2.5)						,	Write(lowercase_)						,	Write(lowercase_))

          self.add(lowercase_)

          SCREAMING_SNAKE_CASE_      :  Any    						=		[]
          SCREAMING_SNAKE_CASE_      :  Any    						=		[]
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		[]
          for i, rect in enumerate(lowercase_):
              SCREAMING_SNAKE_CASE_      :  Any    						=		Rectangle(height=0.46						,	width=0.46).set_stroke(width=0.0).set_fill(lowercase_						,	opacity=0.7)
              cpu_target.move_to(lowercase_)
              cpu_target.generate_target()
              SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		0.46 / 4
              SCREAMING_SNAKE_CASE_      :  str    						=		0.46 / 3

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

              first_animations.append(rect.animate(run_time=0.5).set_stroke(lowercase_))
              second_animations.append(MoveToTarget(lowercase_						,	run_time=1.5))

          self.play(*lowercase_)
          self.play(*lowercase_)

          self.wait()










"""simple docstring"""






import argparse

import torch

from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()



def 					_A			(__a    ,				__a    ,				__a							) ->       Dict:
    """simple docstring"""






    if gpta_config_file == "":
        SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		GPTaConfig()
    else:
        SCREAMING_SNAKE_CASE_      :  Tuple    						=		GPTaConfig.from_json_file(__a							)
    SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		GPTaModel(__a							)

    # Load weights from numpy
    load_tf_weights_in_gpta(__a    ,				__a    ,				__a							)

    # Save pytorch-model
    SCREAMING_SNAKE_CASE_      :  List[str]    						=		pytorch_dump_folder_path + '''/''' + WEIGHTS_NAME
    SCREAMING_SNAKE_CASE_      :  List[Any]    						=		pytorch_dump_folder_path + '''/''' + CONFIG_NAME
    print(f'Save PyTorch model to {pytorch_weights_dump_path}'							)
    torch.save(model.state_dict()    ,				__a							)
    print(f'Save configuration file to {pytorch_config_dump_path}'							)
    with open(__a    ,				'''w'''    ,				encoding='''utf-8'''							) as f:
        f.write(config.to_json_string()							)


if __name__ == "__main__":
  UpperCAmelCase_   : str   			= argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      """--gpt2_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
  )
  parser.add_argument(
      """--pytorch_dump_folder_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
  )
  parser.add_argument(
      """--gpt2_config_file""",
      default="""""",
      type=str,
      help=(
          """An optional config json file corresponding to the pre-trained OpenAI model. \n"""
          """This specifies the model architecture."""
      ),
  )
  UpperCAmelCase_   : Union[str, Any]   			= parser.parse_args()
  convert_gpta_checkpoint_to_pytorch(args.gpta_checkpoint_path, args.gpta_config_file, args.pytorch_dump_folder_path)


