
"""simple docstring"""





from manim import *






class    _UpperCAmelCase(   _a     ):



		def 						UpperCAmelCase							( self)	->	Optional[Any]:






							'''simple docstring'''
							_UpperCamelCase										=  Rectangle(height=0.5    ,		width=0.5)
							_UpperCamelCase										=  Rectangle(height=0.46    ,		width=0.46).set_stroke(width=0)

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

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

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

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

							_UpperCamelCase										=  []
							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)

												_UpperCamelCase										=  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)

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

							_UpperCamelCase										=  Text('''Loaded Checkpoint'''    ,		font_size=24)
							_UpperCamelCase										=  Group(_a    ,		_a).arrange(_a    ,		aligned_edge=_a    ,		buff=0.4)
							checkpoint.move_to([3, 0.5, 0])

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

							_UpperCamelCase										=  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)

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

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

							_UpperCamelCase										=  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))

							_UpperCamelCase										=  []
							_UpperCamelCase										=  []
							for i, rect in enumerate(_a):
												_UpperCamelCase										=  fill.copy().set_fill(_a    ,		opacity=0.7)
												target.move_to(_a)
												first_animations.append(GrowFromCenter(_a    ,		run_time=1))

												_UpperCamelCase										=  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"""





def 				lowerCamelCase__		(      __snake_case,					__snake_case     )							->		str:


					"""simple docstring"""





					if number < 0 or shift_amount < 0:
										raise ValueError('''both inputs must be positive integers'''     )

					_UpperCamelCase										=  str(bin(__snake_case     )     )
					binary_number += "0" * shift_amount
					return binary_number



def 				lowerCamelCase__		(      __snake_case,					__snake_case     )							->		str:


					"""simple docstring"""





					if number < 0 or shift_amount < 0:
										raise ValueError('''both inputs must be positive integers'''     )

					_UpperCamelCase										=  str(bin(__snake_case     )     )[2:]
					if shift_amount >= len(__snake_case     ):
										return "0b0"
					_UpperCamelCase										=  binary_number[: len(__snake_case     ) - shift_amount]
					return "0b" + shifted_binary_number



def 				lowerCamelCase__		(      __snake_case,					__snake_case     )							->		str:


					"""simple docstring"""





					if number >= 0:  # Get binary representation of positive number
										_UpperCamelCase										=  '''0''' + str(bin(__snake_case     )     ).strip('''-'''     )[2:]
					else:  # Get binary (2's complement) representation of negative number
										_UpperCamelCase										=  len(bin(__snake_case     )[3:]     )  # Find 2's complement of number
										_UpperCamelCase										=  bin(abs(__snake_case     ) - (1 << binary_number_length)     )[3:]
										_UpperCamelCase										=  (
										    '''1''' + '''0''' * (binary_number_length - len(__snake_case     )) + binary_number
										)

					if shift_amount >= len(__snake_case     ):
										return "0b" + binary_number[0] * len(__snake_case     )
					return (
					    "0b"
					    + binary_number[0] * shift_amount
					    + binary_number[: len(__snake_case     ) - shift_amount]
					)


if __name__ == "__main__":
				import doctest

				doctest.testmod()






