



from manim import *
class 				_snake_case			(					__UpperCAmelCase):




    def 							A__      (						self					:						List[Any]						):
       lowercase__					  =				Rectangle(height=0.5,					width=0.5						)
       lowercase__					  =				Rectangle(height=0.25,					width=0.25						)
       lowercase__					  =				Rectangle(height=0.46,					width=0.46						).set_stroke(width=0						)

       lowercase__					  =				[mem.copy() for i in range(6						)]
       lowercase__					  =				[mem.copy() for i in range(6						)]
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				VGroup(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				Text("CPU",					font_size=24						)
       lowercase__					  =				Group(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0.5,					aligned_edge=__SCREAMING_SNAKE_CASE						)
       cpu.move_to([-2.5, -0.5, 0]						)
       self.add(__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				[mem.copy() for i in range(4						)]
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				Text("GPU",					font_size=24						)
       lowercase__					  =				Group(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0.5,					aligned_edge=__SCREAMING_SNAKE_CASE						)
       gpu.move_to([-1, -1, 0]						)
       self.add(__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				[mem.copy() for i in range(6						)]
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)

       lowercase__					  =				Text("Model",					font_size=24						)
       lowercase__					  =				Group(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0.5,					aligned_edge=__SCREAMING_SNAKE_CASE						)
       model.move_to([3, -1.0, 0]						)
       self.add(__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				[]
       lowercase__					  =				[]
       lowercase__					  =				[]

       for i, rect in enumerate(__SCREAMING_SNAKE_CASE						):
          rect.set_stroke(__SCREAMING_SNAKE_CASE						)

          lowercase__					  =				Rectangle(height=0.46 / 4,					width=0.46 / 3						).set_stroke(width=0.0						).set_fill(__SCREAMING_SNAKE_CASE,					opacity=0.7						)

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

       self.add(*__SCREAMING_SNAKE_CASE,					*__SCREAMING_SNAKE_CASE,					*__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				[mem.copy() for i in range(6						)]
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)

       lowercase__					  =				Text("Loaded Checkpoint",					font_size=24						)
       lowercase__					  =				Group(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0.5,					aligned_edge=__SCREAMING_SNAKE_CASE						)
       checkpoint.move_to([3, 0.5, 0]						)

       self.add(__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				[]
       lowercase__					  =				[]

       for i, rect in enumerate(__SCREAMING_SNAKE_CASE						):
          lowercase__					  =				fill.copy().set_fill(__SCREAMING_SNAKE_CASE,					opacity=0.7						)
          target.move_to(__SCREAMING_SNAKE_CASE						)
          ckpt_arr.append(__SCREAMING_SNAKE_CASE						)

          lowercase__					  =				target.copy()
          if i < 5:
             cpu_target.move_to(cpu_left_col_base[i + 1]						)
          else:
             cpu_target.move_to(cpu_right_col_base[i - 5]						)
          ckpt_cpu_arr.append(__SCREAMING_SNAKE_CASE						)
       self.add(*__SCREAMING_SNAKE_CASE,					*__SCREAMING_SNAKE_CASE						)

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

       lowercase__					  =				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(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				MarkupText(
           F'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint''',					font_size=18,					)

       blue_text.next_to(__SCREAMING_SNAKE_CASE,					DOWN * 2.4,					aligned_edge=key_text.get_left()						)
       self.add(__SCREAMING_SNAKE_CASE						)

       lowercase__					  =				MarkupText(
           F'''Based on the passed in configuration, weights are stored in\na variety of np.memmaps on disk or to a particular device.''',					font_size=24,					)
       step_a.move_to([2, 2, 0]						)

       lowercase__					  =				[meta_mem.copy() for i in range(6						)]
       lowercase__					  =				[meta_mem.copy() for i in range(6						)]
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				VGroup(*__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				VGroup(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0						)
       lowercase__					  =				Text("Disk",					font_size=24						)
       lowercase__					  =				Group(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE						).arrange(__SCREAMING_SNAKE_CASE,					buff=0.5,					aligned_edge=__SCREAMING_SNAKE_CASE						)
       disk.move_to([-4.0, -1.25, 0]						)
       self.play(Write(__SCREAMING_SNAKE_CASE,					run_time=3						),					Write(__SCREAMING_SNAKE_CASE,					run_time=1						),					Create(__SCREAMING_SNAKE_CASE,					run_time=1						)						)

       lowercase__					  =				[]
       for i, rect in enumerate(__SCREAMING_SNAKE_CASE						):
          lowercase__					  =				rect.copy()
          target.generate_target()
          target.target.move_to(disk_left_col_base[i]						).scale(0.5						)
          animations.append(MoveToTarget(__SCREAMING_SNAKE_CASE,					run_time=1.5						)						)
       self.play(*__SCREAMING_SNAKE_CASE						)

       self.play(FadeOut(__SCREAMING_SNAKE_CASE						)						)

       lowercase__					  =				MarkupText(F'''Then, the checkpoint is removed from memory\nthrough garbage collection.''',					font_size=24						)
       step_a.move_to([2, 2, 0]						)

       self.play(Write(__SCREAMING_SNAKE_CASE,					run_time=3						)						)

       self.play(
           FadeOut(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE,					*__SCREAMING_SNAKE_CASE,					*__SCREAMING_SNAKE_CASE						),					)

       self.wait()









# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from argparse import ArgumentParser

from accelerate.commands.config import get_config_parser
from accelerate.commands.env import env_command_parser
from accelerate.commands.launch import launch_command_parser
from accelerate.commands.test import test_command_parser
from accelerate.commands.tpu import tpu_command_parser



def __lowerCAmelCase (     ):
			lowercase__					  =				ArgumentParser("Accelerate CLI tool"						,  usage="accelerate <command> [<args>]"						,  allow_abbrev=SCREAMING_SNAKE_CASE_  )
			lowercase__					  =				parser.add_subparsers(help="accelerate command helpers"  )

			# Register commands
			get_config_parser(subparsers=SCREAMING_SNAKE_CASE_  )
			env_command_parser(subparsers=SCREAMING_SNAKE_CASE_  )
			launch_command_parser(subparsers=SCREAMING_SNAKE_CASE_  )
			tpu_command_parser(subparsers=SCREAMING_SNAKE_CASE_  )
			test_command_parser(subparsers=SCREAMING_SNAKE_CASE_  )

			# Let's go
			lowercase__					  =				parser.parse_args()

			if not hasattr(SCREAMING_SNAKE_CASE_						,  "func"  ):
						parser.print_help()
						exit(1  )

			# Run
			args.func(SCREAMING_SNAKE_CASE_  )


if __name__ == "__main__":
							main()




