
'''simple docstring'''






import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


A			      =      {
    '<': operator.lt,
    '<=': operator.le,
    '==': operator.eq,
    '!=': operator.ne,
    '>=': operator.ge,
    '>': operator.gt,
}





def    UpperCAmelCase							(  UpperCAmelCase__							:							Optional[Any]       ,							UpperCAmelCase__							:							Optional[Any]       ,							UpperCAmelCase__							:							Union[str, Any]       ,							UpperCAmelCase__							:							List[Any]       ,							UpperCAmelCase__							:							Dict       ,							UpperCAmelCase__							:							Optional[int]):
				if got_ver is None or want_ver is None:
								raise ValueError(
								    F'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
								    F''' reinstalling {pkg}.''')
				if not ops[op](version.parse(UpperCAmelCase__)       ,							version.parse(UpperCAmelCase__)):
								raise ImportError(
								    F'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}''')





def    UpperCAmelCase							(  UpperCAmelCase__							:							str       ,							UpperCAmelCase__							:							Optional[str] = None):
				lowerCamelCase					:			List[Any]									= F'''\n{hint}''' if hint is not None else ''

				# non-versioned check
				if re.match(R'^[\w_\-\d]+$'       ,							UpperCAmelCase__):
								lowerCamelCase			, lowerCamelCase			, lowerCamelCase					:			Optional[Any]									= requirement, None, None
				else:
								lowerCamelCase					:			Optional[Any]									= re.findall(R'^([^!=<>\s]+)([\s!=<>]{1,2}.+)'       ,							UpperCAmelCase__)
								if not match:
												raise ValueError(
												    'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'
												    F''' got {requirement}''')
								lowerCamelCase			, lowerCamelCase					:			Dict									= match[0]
								lowerCamelCase					:			Dict									= want_full.split(',')  # there could be multiple requirements
								lowerCamelCase					:			Union[str, Any]									= {}
								for w in want_range:
												lowerCamelCase					:			int									= re.findall(R'^([\s!=<>]{1,2})(.+)'       ,							UpperCAmelCase__)
												if not match:
																raise ValueError(
																    'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'
																    F''' but got {requirement}''')
												lowerCamelCase			, lowerCamelCase					:			List[Any]									= match[0]
												lowerCamelCase					:			Optional[int]									= want_ver
												if op not in ops:
																raise ValueError(F'''{requirement}: need one of {list(ops.keys())}, but got {op}''')

    # special case
				if pkg == "python":
								lowerCamelCase					:			Optional[int]									= '.'.join([str(UpperCAmelCase__) for x in sys.version_info[:3]])
								for op, want_ver in wanted.items():
												_compare_versions(UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__)
								return

				# check if any version is installed
				try:
								lowerCamelCase					:			Any									= importlib.metadata.version(UpperCAmelCase__)
				except importlib.metadata.PackageNotFoundError:
								raise importlib.metadata.PackageNotFoundError(
								    F'''The \'{requirement}\' distribution was not found and is required by this application. {hint}''')

				# check that the right version is installed if version number or a range was provided
				if want_ver is not None:
								for op, want_ver in wanted.items():
												_compare_versions(UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__)





def    UpperCAmelCase							(  UpperCAmelCase__							:							str):
				lowerCamelCase					:			List[str]									= 'Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'
				return require_version(UpperCAmelCase__       ,							UpperCAmelCase__)


'''simple docstring'''






from manim import *




class     __snake_case		(   a__):
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


									lowerCamelCase					:			Optional[int]									= Rectangle(height=0.5,    width=0.5      )
									lowerCamelCase					:			List[Any]									= Rectangle(height=0.46,    width=0.46      ).set_stroke(width=0      )

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

									lowerCamelCase					:			Optional[int]									= [mem.copy() for i in range(1      )]
									lowerCamelCase					:			Union[str, Any]									= VGroup(*A      ).arrange(A,    buff=0      )
									lowerCamelCase					:			Optional[Any]									= Text('GPU',    font_size=24      )
									lowerCamelCase					:			Tuple									= Group(A,    A      ).arrange(A,    buff=0.5,    aligned_edge=A      )
									gpu.align_to(A,    A      )
									gpu.set_x(gpu.get_x() - 1      )

									self.add(A      )

									lowerCamelCase					:			Optional[int]									= [mem.copy() for i in range(6      )]
									lowerCamelCase					:			Optional[Any]									= VGroup(*A      ).arrange(A,    buff=0      )

									lowerCamelCase					:			Any									= Text('Model',    font_size=24      )
									lowerCamelCase					:			Tuple									= Group(A,    A      ).arrange(A,    buff=0.5,    aligned_edge=A      )
									model.move_to([3, -1.0, 0]      )

									self.play(
									    Create(A,    run_time=1      ),    Create(A,    run_time=1      ),    Create(A,    run_time=1      ),    )

									lowerCamelCase					:			str									= MarkupText(
									    F'''First, an empty model skeleton is loaded\ninto <span fgcolor=\'{YELLOW}\'>memory</span> without using much RAM.''',    font_size=24,    )

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

									lowerCamelCase					:			Tuple									= MarkupText(
									    F'''<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model''',    font_size=18,    )

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

									step_a.move_to([2, 2, 0]      )
									self.play(Write(A,    run_time=2.5      ),    Write(A      ),    Write(A      )      )

									self.add(A      )

									lowerCamelCase					:			str									= []
									lowerCamelCase					:			Optional[int]									= []
									lowerCamelCase					:			Optional[Any]									= []
									for i, rect in enumerate(A      ):
													lowerCamelCase					:			List[str]									= Rectangle(height=0.46,    width=0.46      ).set_stroke(width=0.0      ).set_fill(A,    opacity=0.7      )
													cpu_target.move_to(A      )
													cpu_target.generate_target()
													lowerCamelCase					:			int									= 0.46 / 4
													lowerCamelCase					:			Optional[int]									= 0.46 / 3

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

													first_animations.append(rect.animate(run_time=0.5      ).set_stroke(A      )      )
													second_animations.append(MoveToTarget(A,    run_time=1.5      )      )

									self.play(*A      )
									self.play(*A      )

									self.wait()
