


from manim import *






class 	__lowercase					(	__snake_case	):





      def 							_lowercase					(		self    :       str							)     -> str:






         """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=2_4							)
         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(4							)]
         UpperCAmelCase      					=  VGroup(*__lowerCamelCase							).arrange(__lowerCamelCase       ,							buff=0							)
         UpperCAmelCase      					=  Text("""GPU"""       ,							font_size=2_4							)
         UpperCAmelCase      					=  Group(__lowerCamelCase       ,							__lowerCamelCase							).arrange(__lowerCamelCase       ,							buff=0.5       ,							aligned_edge=__lowerCamelCase							)
         gpu.move_to([-1, -1, 0]							)
         self.add(__lowerCamelCase							)

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

         UpperCAmelCase      					=  Text("""Model"""       ,							font_size=2_4							)
         UpperCAmelCase      					=  Group(__lowerCamelCase       ,							__lowerCamelCase							).arrange(__lowerCamelCase       ,							buff=0.5       ,							aligned_edge=__lowerCamelCase							)
         model.move_to([3, -1.0, 0]							)
         self.add(__lowerCamelCase							)

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

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

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

         UpperCAmelCase      					=  Text("""Loaded Checkpoint"""       ,							font_size=2_4							)
         UpperCAmelCase      					=  Group(__lowerCamelCase       ,							__lowerCamelCase							).arrange(__lowerCamelCase       ,							aligned_edge=__lowerCamelCase       ,							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=1_8       ,							)

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

         self.add(__lowerCamelCase       ,							__lowerCamelCase							)

         UpperCAmelCase      					=  MarkupText(
             F"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""       ,							font_size=1_8       ,							)

         blue_text.next_to(__lowerCamelCase       ,							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=2_4       ,							)
         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							)							)

         UpperCAmelCase      					=  []
         UpperCAmelCase      					=  []
         for i, rect in enumerate(__lowerCamelCase							):
            UpperCAmelCase      					=  fill.copy().set_fill(__lowerCamelCase       ,							opacity=0.7							)
            target.move_to(__lowerCamelCase							)
            first_animations.append(GrowFromCenter(__lowerCamelCase       ,							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(__lowerCamelCase       ,							run_time=1.5							)							)

         self.play(*__lowerCamelCase							)
         self.play(*__lowerCamelCase							)
         self.wait()







from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType






class 	__lowercase					(	__snake_case	):
      UpperCamelCase										=							['''image_processor''', '''tokenizer''']
      UpperCamelCase										=							'''BridgeTowerImageProcessor'''
      UpperCamelCase										=							('''RobertaTokenizer''', '''RobertaTokenizerFast''')





      def __init__(		self    :       int       ,							__lowerCamelCase    :       Tuple       ,							__lowerCamelCase    :       List[Any]							)     -> Union[str, Any]:






         """simple docstring"""







         super().__init__(__lowerCamelCase       ,							__lowerCamelCase							)





      def __call__(		self    :       Any       ,							__lowerCamelCase    :       Optional[int]       ,							__lowerCamelCase    :       Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None       ,							__lowerCamelCase    :       bool = True       ,							__lowerCamelCase    :       Union[bool, str, PaddingStrategy] = False       ,							__lowerCamelCase    :       Union[bool, str, TruncationStrategy] = None       ,							__lowerCamelCase    :       Optional[int] = None       ,							__lowerCamelCase    :       int = 0       ,							__lowerCamelCase    :       Optional[int] = None       ,							__lowerCamelCase    :       Optional[bool] = None       ,							__lowerCamelCase    :       Optional[bool] = None       ,							__lowerCamelCase    :       bool = False       ,							__lowerCamelCase    :       bool = False       ,							__lowerCamelCase    :       bool = False       ,							__lowerCamelCase    :       bool = False       ,							__lowerCamelCase    :       bool = True       ,							__lowerCamelCase    :       Optional[Union[str, TensorType]] = None       ,							**__lowerCamelCase    :       Dict       ,							)     -> BatchEncoding:






         """simple docstring"""







         UpperCAmelCase      					=  self.tokenizer(
             text=__lowerCamelCase       ,							add_special_tokens=__lowerCamelCase       ,							padding=__lowerCamelCase       ,							truncation=__lowerCamelCase       ,							max_length=__lowerCamelCase       ,							stride=__lowerCamelCase       ,							pad_to_multiple_of=__lowerCamelCase       ,							return_token_type_ids=__lowerCamelCase       ,							return_attention_mask=__lowerCamelCase       ,							return_overflowing_tokens=__lowerCamelCase       ,							return_special_tokens_mask=__lowerCamelCase       ,							return_offsets_mapping=__lowerCamelCase       ,							return_length=__lowerCamelCase       ,							verbose=__lowerCamelCase       ,							return_tensors=__lowerCamelCase       ,							**__lowerCamelCase       ,							)
         # add pixel_values + pixel_mask
         UpperCAmelCase      					=  self.image_processor(
             __lowerCamelCase       ,							return_tensors=__lowerCamelCase       ,							do_normalize=__lowerCamelCase       ,							do_center_crop=__lowerCamelCase       ,							**__lowerCamelCase							)
         encoding.update(__lowerCamelCase							)

         return encoding





      def 							_lowercase					(		self    :       Optional[Any]       ,							*__lowerCamelCase    :       Optional[int]       ,							**__lowerCamelCase    :       List[str]							)     -> str:






         """simple docstring"""







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





      def 							_lowercase					(		self    :       Dict       ,							*__lowerCamelCase    :       Any       ,							**__lowerCamelCase    :       List[Any]							)     -> Optional[int]:






         """simple docstring"""







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





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






         """simple docstring"""







         UpperCAmelCase      					=  self.tokenizer.model_input_names
         UpperCAmelCase      					=  self.image_processor.model_input_names
         return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)



