"""simple docstring"""





from manim import *


class      UpperCAmelCase_	(    _a):


      def 		_UpperCAmelCase       (   self							)       ->					str:
             lowercase__			:		int       =	Rectangle(height=0.5		,			width=0.5							)
             lowercase__			:		List[Any]       =	Rectangle(height=0.46		,			width=0.46							).set_stroke(width=0							)

             lowercase__			:		Optional[Any]       =	Rectangle(height=0.25		,			width=0.25							)

             lowercase__			:		Optional[int]       =	[mem.copy() for i in range(6							)]
             lowercase__			:		Tuple       =	[mem.copy() for i in range(6							)]
             lowercase__			:		str       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		str       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		str       =	VGroup(a		,			a							).arrange(a		,			buff=0							)
             lowercase__			:		Dict       =	Text('CPU'		,			font_size=2_4							)
             lowercase__			:		Dict       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             cpu.move_to([-2.5, -0.5, 0]							)
             self.add(a							)

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

             lowercase__			:		Tuple       =	[mem.copy() for i in range(6							)]
             lowercase__			:		List[Any]       =	VGroup(*a							).arrange(a		,			buff=0							)

             lowercase__			:		Union[str, Any]       =	Text('Model'		,			font_size=2_4							)
             lowercase__			:		Any       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             model.move_to([3, -1.0, 0]							)
             self.add(a							)

             lowercase__			:		int       =	[]
             lowercase__			:		Tuple       =	[]

             for i, rect in enumerate(a							):
                    lowercase__			:		List[Any]       =	fill.copy().set_fill(a		,			opacity=0.8							)
                    target.move_to(a							)
                    model_arr.append(a							)

                    lowercase__			:		List[Any]       =	Rectangle(height=0.46		,			width=0.46							).set_stroke(width=0.0							).set_fill(a		,			opacity=0.8							)
                    cpu_target.move_to(cpu_left_col_base[i]							)
                    model_cpu_arr.append(a							)

             self.add(*a		,			*a							)

             lowercase__			:		Tuple       =	[meta_mem.copy() for i in range(6							)]
             lowercase__			:		List[Any]       =	[meta_mem.copy() for i in range(6							)]
             lowercase__			:		Any       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		Any       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		Any       =	VGroup(a		,			a							).arrange(a		,			buff=0							)
             lowercase__			:		Tuple       =	Text('Disk'		,			font_size=2_4							)
             lowercase__			:		List[str]       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             disk.move_to([-4, -1.25, 0]							)
             self.add(a		,			a							)

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

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

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

             self.add(a		,			a							)

             lowercase__			:		Optional[int]       =	MarkupText(
                 f"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""		,			font_size=1_8		,			)

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

             lowercase__			:		str       =	MarkupText(
                 f"""Now watch as an input is passed through the model\nand how the memory is utilized and handled."""		,			font_size=2_4		,			)
             step_a.move_to([2, 2, 0]							)

             self.play(Write(a							)							)

             lowercase__			:		List[Any]       =	Square(0.3							)
             input.set_fill(a		,			opacity=1.0							)
             input.set_stroke(width=0.0							)
             input.next_to(model_base[0]		,			a		,			buff=0.5							)

             self.play(Write(a							)							)

             input.generate_target()
             input.target.next_to(model_arr[0]		,			direction=a		,			buff=0.02							)
             self.play(MoveToTarget(a							)							)

             self.play(FadeOut(a							)							)

             lowercase__			:		Any       =	Arrow(start=a		,			end=a		,			color=a		,			buff=0.5							)
             a.next_to(model_arr[0].get_left()		,			a		,			buff=0.2							)

             model_cpu_arr[0].generate_target()
             model_cpu_arr[0].target.move_to(gpu_rect[0]							)

             lowercase__			:		List[str]       =	MarkupText(
                 f"""As the input reaches a layer, the hook triggers\nand weights are moved from the CPU\nto the GPU and back."""		,			font_size=2_4		,			)
             step_a.move_to([2, 2, 0]							)

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

             lowercase__			:		Optional[Any]       =	{'run_time': 1, 'fade_in': True, 'fade_out': True, 'buff': 0.02}

             self.play(
                 Write(a							)		,			Circumscribe(model_arr[0]		,			color=a		,			**a							)		,			Circumscribe(model_cpu_arr[0]		,			color=a		,			**a							)		,			Circumscribe(gpu_rect[0]		,			color=a		,			**a							)		,			)
             self.play(MoveToTarget(model_cpu_arr[0]							)							)

             lowercase__			:		Tuple       =	a.copy()
             for i in range(6							):
                    a_c.next_to(model_arr[i].get_right() + 0.02		,			a		,			buff=0.2							)

                    input.generate_target()
                    input.target.move_to(model_arr[i].get_right() + 0.02							)

                    lowercase__			:		Union[str, Any]       =	AnimationGroup(
                        FadeOut(a		,			run_time=0.5							)		,			MoveToTarget(a		,			run_time=0.5							)		,			FadeIn(a		,			run_time=0.5							)		,			lag_ratio=0.2							)

                    self.play(a							)

                    model_cpu_arr[i].generate_target()
                    model_cpu_arr[i].target.move_to(cpu_left_col_base[i]							)

                    if i < 5:
                           model_cpu_arr[i + 1].generate_target()
                           model_cpu_arr[i + 1].target.move_to(gpu_rect[0]							)
                           if i >= 1:
                                  lowercase__			:		List[str]       =	0.7

                           self.play(
                               Circumscribe(model_arr[i]		,			**a							)		,			Circumscribe(cpu_left_col_base[i]		,			**a							)		,			Circumscribe(cpu_left_col_base[i + 1]		,			color=a		,			**a							)		,			Circumscribe(gpu_rect[0]		,			color=a		,			**a							)		,			Circumscribe(model_arr[i + 1]		,			color=a		,			**a							)		,			)
                           if i < 1:
                                  self.play(
                                      MoveToTarget(model_cpu_arr[i]							)		,			MoveToTarget(model_cpu_arr[i + 1]							)		,			)
                           else:
                                  self.play(
                                      MoveToTarget(model_cpu_arr[i]		,			run_time=0.7							)		,			MoveToTarget(model_cpu_arr[i + 1]		,			run_time=0.7							)		,			)
                    else:
                           model_cpu_arr[i].generate_target()
                           model_cpu_arr[i].target.move_to(cpu_left_col_base[-1]							)
                           input.generate_target()
                           input.target.next_to(model_arr[-1].get_right()		,			RIGHT + 0.02		,			buff=0.2							)

                           self.play(
                               Circumscribe(model_arr[-1]		,			color=a		,			**a							)		,			Circumscribe(cpu_left_col_base[-1]		,			color=a		,			**a							)		,			Circumscribe(gpu_rect[0]		,			color=a		,			**a							)		,			)

                           self.play(MoveToTarget(model_cpu_arr[i]							)							)

                    lowercase__			:		Optional[Any]       =	a_c
                    lowercase__			:		Optional[int]       =	a_c.copy()

             input.generate_target()
             input.target.next_to(model_base[-1]		,			RIGHT + 0.02		,			buff=0.5							)
             self.play(
                 FadeOut(a							)		,			FadeOut(a		,			run_time=0.5							)		,			)

             lowercase__			:		Optional[Any]       =	MarkupText(f"""Inference on a model too large for GPU memory\nis successfully completed."""		,			font_size=2_4							)
             step_a.move_to([2, 2, 0]							)

             self.play(Write(a		,			run_time=3							)		,			MoveToTarget(a							)							)

             self.wait()








def A_	(		A__		,      A__				)  ->		str:
       if a < 0 or b < 0:
              raise ValueError('the value of both inputs must be positive'				)

       a__						:	List[str] =				str(bin(A__				)				)[2:]  # remove the leading "0b"
       a__						:	Optional[int] =				str(bin(A__				)				)[2:]  # remove the leading "0b"

       a__						:	List[str] =				max(len(A__				)		,      len(A__				)				)

       return "0b" + "".join(
           str(int(char_a == '1' and char_b == '1'				)				)
           for char_a, char_b in zip(a_binary.zfill(A__				)		,      b_binary.zfill(A__				)				)				)


if __name__ == "__main__":
    import doctest

    doctest.testmod()


