






'''simple docstring'''



from manim import *






class 	UpperCamelCase__(       snake_case_	):




				def 					a__(		self      :			Optional[Any]				)->					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(*lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0				)
										UpperCAmelCase					    =     VGroup(*lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0				)
										UpperCAmelCase					    =     VGroup(lowerCAmelCase				,   lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0				)
										UpperCAmelCase					    =     Text('''CPU'''				,   font_size=24				)
										UpperCAmelCase					    =     Group(lowerCAmelCase				,   lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0.5				,   aligned_edge=lowerCAmelCase				)
										cpu.move_to([-2.5, -0.5, 0]				)
										self.add(lowerCAmelCase				)

										UpperCAmelCase					    =     [mem.copy() for i in range(1				)]
										UpperCAmelCase					    =     VGroup(*lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0				)
										UpperCAmelCase					    =     Text('''GPU'''				,   font_size=24				)
										UpperCAmelCase					    =     Group(lowerCAmelCase				,   lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0.5				,   aligned_edge=lowerCAmelCase				)
										gpu.align_to(lowerCAmelCase				,   lowerCAmelCase				)
										gpu.set_x(gpu.get_x() - 1				)

										self.add(lowerCAmelCase				)

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

										UpperCAmelCase					    =     Text('''Model'''				,   font_size=24				)
										UpperCAmelCase					    =     Group(lowerCAmelCase				,   lowerCAmelCase				).arrange(lowerCAmelCase				,   buff=0.5				,   aligned_edge=lowerCAmelCase				)
										model.move_to([3, -1.0, 0]				)

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

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

										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]				)

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

										self.add(lowerCAmelCase				)

										UpperCAmelCase					    =     []
										UpperCAmelCase					    =     []
										UpperCAmelCase					    =     []
										for i, rect in enumerate(lowerCAmelCase				):
																UpperCAmelCase					    =     Rectangle(height=0.46				,   width=0.46				).set_stroke(width=0.0				).set_fill(lowerCAmelCase				,   opacity=0.7				)
																cpu_target.move_to(lowerCAmelCase				)
																cpu_target.generate_target()
																UpperCAmelCase					    =     0.46 / 4
																UpperCAmelCase					    =     0.46 / 3

																if i == 0:
																						cpu_target.target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT				)				,   buff=0.02				,   direction=lowerCAmelCase				)
																						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=lowerCAmelCase				,   buff=0.0				)
																else:
																						cpu_target.target.next_to(cpu_targs[i - 1].target				,   direction=lowerCAmelCase				,   buff=0.0				)
																cpu_targs.append(lowerCAmelCase				)

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

										self.play(*lowerCAmelCase				)
										self.play(*lowerCAmelCase				)

										self.wait()









'''simple docstring'''



import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding






class 	UpperCamelCase__(       lowerCAmelCase	):
				__magic_name__    :				List[Any]  		=	["image_processor", "tokenizer"]
				__magic_name__    :				Tuple  		=	"ViTImageProcessor"
				__magic_name__    :				int  		=	("CLIPTokenizer", "CLIPTokenizerFast")




				def __init__(		self      :			List[str]				,   lowerCAmelCase      :			Tuple=None				,   lowerCAmelCase      :			List[str]=None				,   **lowerCAmelCase      :			Optional[int]				)->					Tuple:

										"""simple docstring"""




										UpperCAmelCase					    =     None
										if "feature_extractor" in kwargs:
																warnings.warn(
																    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
																    ''' instead.'''				,   lowerCAmelCase				,   )
																UpperCAmelCase					    =     kwargs.pop('''feature_extractor'''				)

										UpperCAmelCase					    =     image_processor if image_processor is not None else feature_extractor
										if image_processor is None:
																raise ValueError('''You need to specify an `image_processor`.'''				)
										if tokenizer is None:
																raise ValueError('''You need to specify a `tokenizer`.'''				)

										super().__init__(lowerCAmelCase				,   lowerCAmelCase				)




				def __call__(		self      :			int				,   lowerCAmelCase      :			Dict=None				,   lowerCAmelCase      :			Optional[int]=None				,   lowerCAmelCase      :			Union[str, Any]=None				,   lowerCAmelCase      :			int=None				,   **lowerCAmelCase      :			Tuple				)->					Optional[int]:

										"""simple docstring"""




										if text is None and visual_prompt is None and images is None:
																raise ValueError('''You have to specify either text, visual prompt or images.'''				)

										if text is not None and visual_prompt is not None:
																raise ValueError('''You have to specify exactly one type of prompt. Either text or visual prompt.'''				)

										if text is not None:
																UpperCAmelCase					    =     self.tokenizer(lowerCAmelCase				,   return_tensors=lowerCAmelCase				,   **lowerCAmelCase				)

										if visual_prompt is not None:
																UpperCAmelCase					    =     self.image_processor(lowerCAmelCase				,   return_tensors=lowerCAmelCase				,   **lowerCAmelCase				)

										if images is not None:
																UpperCAmelCase					    =     self.image_processor(lowerCAmelCase				,   return_tensors=lowerCAmelCase				,   **lowerCAmelCase				)

										if visual_prompt is not None and images is not None:
																UpperCAmelCase					    =     {
																    '''pixel_values''': image_features.pixel_values,
																    '''conditional_pixel_values''': prompt_features.pixel_values,
																}
																return encoding
										elif text is not None and images is not None:
																UpperCAmelCase					    =     image_features.pixel_values
																return encoding
										elif text is not None:
																return encoding
										elif visual_prompt is not None:
																UpperCAmelCase					    =     {
																    '''conditional_pixel_values''': prompt_features.pixel_values,
																}
																return encoding
										else:
																return BatchEncoding(data=dict(**lowerCAmelCase				)				,   tensor_type=lowerCAmelCase				)




				def 					a__(		self      :			Optional[int]				,   *lowerCAmelCase      :			List[str]				,   **lowerCAmelCase      :			Dict				)->					Tuple:

										"""simple docstring"""




										return self.tokenizer.batch_decode(*lowerCAmelCase				,   **lowerCAmelCase				)




				def 					a__(		self      :			List[Any]				,   *lowerCAmelCase      :			str				,   **lowerCAmelCase      :			List[Any]				)->					Optional[Any]:

										"""simple docstring"""




										return self.tokenizer.decode(*lowerCAmelCase				,   **lowerCAmelCase				)




				@property
				def 					a__(		self      :			Any				)->					Optional[int]:

										"""simple docstring"""




										warnings.warn(
										    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''				,   lowerCAmelCase				,   )
										return self.image_processor_class





				@property
				def 					a__(		self      :			str				)->					List[Any]:

										"""simple docstring"""




										warnings.warn(
										    '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''				,   lowerCAmelCase				,   )
										return self.image_processor





