"""simple docstring"""







from manim import *






class 							__snake_case(					_lowerCAmelCase	):


    '''simple docstring'''





    def 						_a							(  self	):




         '''simple docstring'''



         __A					:					Optional[Any]								=		Rectangle(height=0.5					,       width=0.5	)
         __A					:					List[str]								=		Rectangle(height=0.46					,       width=0.46	).set_stroke(width=0	)
         __A					:					Tuple								=		Rectangle(height=0.25					,       width=0.25	)

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

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

         __A					:					str								=		[mem.copy() for i in range(6	)]
         __A					:					Any								=		VGroup(*lowerCAmelCase__	).arrange(lowerCAmelCase__					,       buff=0	)

         __A					:					Any								=		Text('Model'					,       font_size=24	)
         __A					:					List[str]								=		Group(lowerCAmelCase__					,       lowerCAmelCase__	).arrange(lowerCAmelCase__					,       buff=0.5					,       aligned_edge=lowerCAmelCase__	)
         model.move_to([3, -1.0, 0]	)
         self.add(lowerCAmelCase__	)

         __A					:					str								=		[]
         __A					:					Union[str, Any]								=		[]

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

              __A					:					Any								=		Rectangle(height=0.46 / 4					,       width=0.46 / 3	).set_stroke(width=0.0	).set_fill(lowerCAmelCase__					,       opacity=0.7	)

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

         self.add(*lowerCAmelCase__					,       *lowerCAmelCase__	)

         __A					:					Optional[Any]								=		[meta_mem.copy() for i in range(6	)]
         __A					:					int								=		[meta_mem.copy() for i in range(6	)]
         __A					:					Tuple								=		VGroup(*lowerCAmelCase__	).arrange(lowerCAmelCase__					,       buff=0	)
         __A					:					Any								=		VGroup(*lowerCAmelCase__	).arrange(lowerCAmelCase__					,       buff=0	)
         __A					:					Any								=		VGroup(lowerCAmelCase__					,       lowerCAmelCase__	).arrange(lowerCAmelCase__					,       buff=0	)
         __A					:					List[Any]								=		Text('Disk'					,       font_size=24	)
         __A					:					int								=		Group(lowerCAmelCase__					,       lowerCAmelCase__	).arrange(lowerCAmelCase__					,       buff=0.5					,       aligned_edge=lowerCAmelCase__	)
         disk.move_to([-4.0, -1.25, 0]	)
         self.add(lowerCAmelCase__					,       lowerCAmelCase__	)

         __A					:					List[str]								=		[]

         for i in range(6	):
              __A					:					str								=		fill.copy().set_fill(lowerCAmelCase__					,       opacity=0.8	)
              target.move_to(disk_left_col_base[i]	).scale(0.5	)
              cpu_disk_arr.append(lowerCAmelCase__	)

         self.add(*lowerCAmelCase__	)

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

         __A					:					int								=		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(lowerCAmelCase__					,       lowerCAmelCase__	)

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

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

         __A					:					Any								=		MarkupText(F'The offloaded weights are all sent to the CPU.'					,       font_size=24	)
         step_a.move_to([2, 2, 0]	)

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

         for i in range(6	):
              __A					:					Any								=		cpu_disk_arr[i]
              __A					:					Any								=		rect.copy().set_fill(lowerCAmelCase__					,       opacity=0.8	).scale(2.0	)
              cpa.generate_target()
              cpa.target.move_to(model_base[i]	)

              if i == 0:
                   rect.set_fill(lowerCAmelCase__					,       opacity=0.8	)
                   rect.generate_target()
                   rect.target.move_to(cpu_left_col_base[0]	).scale(2.0	)

                   self.remove(
                       *lowerCAmelCase__					,       *lowerCAmelCase__					,       )

              else:
                   rect.generate_target()
                   rect.target.move_to(cpu_left_col_base[i]	).scale(2.0	)
              self.play(MoveToTarget(lowerCAmelCase__	)					,       MoveToTarget(lowerCAmelCase__	)					,       model_base[i].animate.set_stroke(lowerCAmelCase__	)	)
         self.play(FadeOut(lowerCAmelCase__	)	)

         __A					:					Dict								=		MarkupText(
             F'Finally, hooks are added to each weight in the model\nto transfer the weights from CPU to GPU\n\t\tand back when needed.'					,       font_size=24					,       )
         step_a.move_to([2, 2, 0]	)

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

         __A					:					Dict								=		[]
         __A					:					Any								=		[]
         for i in range(6	):
              __A					:					Optional[Any]								=		Arrow(start=lowerCAmelCase__					,       end=lowerCAmelCase__					,       color=lowerCAmelCase__					,       buff=0.5	)
              a.next_to(model_base[i].get_left()					,       lowerCAmelCase__					,       buff=0.2	)
              arrows.append(lowerCAmelCase__	)
              animations.append(Write(lowerCAmelCase__	)	)
         self.play(*lowerCAmelCase__	)
         self.wait()










"""simple docstring"""




import os
import sys
import time

from . import transposition_cipher as trans_cipher





def 			a_							(				):
						_UpperCamelCase     :   Dict      =       '''Prehistoric Men.txt'''
						_UpperCamelCase     :   Optional[Any]      =       '''Output.txt'''
						_UpperCamelCase     :   Any      =       int(input('''Enter key: '''  )  )
						_UpperCamelCase     :   Optional[Any]      =       input('''Encrypt/Decrypt [e/d]: '''  )

						if not os.path.exists(_lowercase  ):
												print(F"""File {input_file} does not exist. Quitting..."""  )
												sys.exit()
						if os.path.exists(_lowercase  ):
												print(F"""Overwrite {output_file}? [y/n]"""  )
												_UpperCamelCase     :   Optional[int]      =       input('''> '''  )
												if not response.lower().startswith('''y'''  ):
																		sys.exit()

						_UpperCamelCase     :   List[str]      =       time.time()
						if mode.lower().startswith('''e'''  ):
												with open(_lowercase  ) as f:
																		_UpperCamelCase     :   Optional[int]      =       f.read()
												_UpperCamelCase     :   List[str]      =       trans_cipher.encrypt_message(_lowercase			,		_lowercase  )
						elif mode.lower().startswith('''d'''  ):
												with open(_lowercase  ) as f:
																		_UpperCamelCase     :   Dict      =       f.read()
												_UpperCamelCase     :   Any      =       trans_cipher.decrypt_message(_lowercase			,		_lowercase  )

						with open(_lowercase			,		'''w'''  ) as output_obj:
												output_obj.write(_lowercase  )

						_UpperCamelCase     :   List[str]      =       round(time.time() - start_time			,		2  )
						print(('''Done (''', total_time, '''seconds )''')  )


if __name__ == "__main__":
						main()



