from manim import *







class __snake_case       (		a__	):




			def 			__a		(					self    :       Optional[Any]   ):



					"""simple docstring"""






					SCREAMING_SNAKE_CASE__    							=   Rectangle(height=0.5 ,			width=0.5   )
					SCREAMING_SNAKE_CASE__    							=   Rectangle(height=0.46 ,			width=0.46   ).set_stroke(width=0   )

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

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

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

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

					SCREAMING_SNAKE_CASE__    							=   []
					for i, rect in enumerate(lowerCamelCase_   ):
							rect.set_stroke(lowerCamelCase_   )
							# target = fill.copy().set_fill(YELLOW, opacity=0.7)
							# target.move_to(rect)
							# self.add(target)

							SCREAMING_SNAKE_CASE__    							=   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(cpu_targs[0] ,			direction=lowerCamelCase_ ,			buff=0.0   )
							else:
									cpu_target.next_to(cpu_targs[i - 1] ,			direction=lowerCamelCase_ ,			buff=0.0   )
							self.add(lowerCamelCase_   )
							cpu_targs.append(lowerCamelCase_   )

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

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

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

					SCREAMING_SNAKE_CASE__    							=   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_   )

					SCREAMING_SNAKE_CASE__    							=   MarkupText(
					    f"""<span fgcolor='{BLUE}'>●</span> Checkpoint""" ,			font_size=18 ,			)

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

					SCREAMING_SNAKE_CASE__    							=   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(lowerCamelCase_   ) ,			Write(lowerCamelCase_   )   )

					self.play(Write(lowerCamelCase_ ,			run_time=1   ) ,			Create(lowerCamelCase_ ,			run_time=1   )   )

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

							SCREAMING_SNAKE_CASE__    							=   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(lowerCamelCase_ ,			run_time=1.5   )   )

					self.play(*lowerCamelCase_   )
					self.play(*lowerCamelCase_   )
					self.wait()

import os

__lowerCamelCase    :				Union[str, Any]							     =	{'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000}



def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: str			)							->      int:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   0

  SCREAMING_SNAKE_CASE__    							=   0
  while index < len(__UpperCamelCase			) - 1:
    SCREAMING_SNAKE_CASE__    							=   SYMBOLS[numerals[index]]
    SCREAMING_SNAKE_CASE__    							=   SYMBOLS[numerals[index + 1]]
    if current_value < next_value:
      total_value -= current_value
    else:
      total_value += current_value
    index += 1
  total_value += SYMBOLS[numerals[index]]

  return total_value



def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: int			)							->      str:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   """"""

  SCREAMING_SNAKE_CASE__    							=   num // 10_00
  numerals += m_count * "M"
  num %= 10_00

  SCREAMING_SNAKE_CASE__    							=   num // 1_00
  if c_count == 9:
    numerals += "CM"
    c_count -= 9
  elif c_count == 4:
    numerals += "CD"
    c_count -= 4
  if c_count >= 5:
    numerals += "D"
    c_count -= 5
  numerals += c_count * "C"
  num %= 1_00

  SCREAMING_SNAKE_CASE__    							=   num // 10
  if x_count == 9:
    numerals += "XC"
    x_count -= 9
  elif x_count == 4:
    numerals += "XL"
    x_count -= 4
  if x_count >= 5:
    numerals += "L"
    x_count -= 5
  numerals += x_count * "X"
  num %= 10

  if num == 9:
    numerals += "IX"
    num -= 9
  elif num == 4:
    numerals += "IV"
    num -= 4
  if num >= 5:
    numerals += "V"
    num -= 5
  numerals += num * "I"

  return numerals



def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: str = "/p089_roman.txt"			)							->      int:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   0

  with open(os.path.dirname(__UpperCamelCase			) + roman_numerals_filename			) as filea:
    SCREAMING_SNAKE_CASE__    							=   filea.readlines()

  for line in lines:
    SCREAMING_SNAKE_CASE__    							=   line.strip()
    SCREAMING_SNAKE_CASE__    							=   parse_roman_numerals(__UpperCamelCase			)
    SCREAMING_SNAKE_CASE__    							=   generate_roman_numerals(__UpperCamelCase			)
    savings += len(__UpperCamelCase			) - len(__UpperCamelCase			)

  return savings


if __name__ == "__main__":
   print(F"""{solution() = }""")
