





'''simple docstring'''






from ...configuration_utils import PretrainedConfig
from ...utils import logging


A__    :       Tuple              =logging.get_logger(__name__)

A__    :       Optional[int]              ={
    '''microsoft/swinv2-tiny-patch4-window8-256''': (
        '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json'''
    ),
}




class 			UpperCAmelCase					(      snake_case_       ):
      _lowercase:      int											=       '''swinv2'''

      _lowercase:      Optional[Any]											=       {
          '''num_attention_heads''': '''num_heads''',
          '''num_hidden_layers''': '''num_layers''',
      }




      def __init__(      self      :			Dict      ,      __snake_case      :			Tuple=2_24      ,      __snake_case      :			Optional[int]=4      ,      __snake_case      :			List[Any]=3      ,      __snake_case      :			List[Any]=96      ,      __snake_case      :			Optional[Any]=[2, 2, 6, 2]      ,      __snake_case      :			Union[str, Any]=[3, 6, 12, 24]      ,      __snake_case      :			Dict=7      ,      __snake_case      :			Tuple=4.0      ,      __snake_case      :			List[Any]=True      ,      __snake_case      :			Optional[Any]=0.0      ,      __snake_case      :			Optional[Any]=0.0      ,      __snake_case      :			Optional[Any]=0.1      ,      __snake_case      :			Optional[int]="gelu"      ,      __snake_case      :			List[str]=False      ,      __snake_case      :			Dict=0.02      ,      __snake_case      :			Optional[Any]=1E-5      ,      __snake_case      :			Dict=32      ,      **__snake_case      :			Any      ,      )    ->				Optional[int]:
            super().__init__(**__a  )

            _lowerCAmelCase												=							image_size
            _lowerCAmelCase												=							patch_size
            _lowerCAmelCase												=							num_channels
            _lowerCAmelCase												=							embed_dim
            _lowerCAmelCase												=							depths
            _lowerCAmelCase												=							len(__a  )
            _lowerCAmelCase												=							num_heads
            _lowerCAmelCase												=							window_size
            _lowerCAmelCase												=							mlp_ratio
            _lowerCAmelCase												=							qkv_bias
            _lowerCAmelCase												=							hidden_dropout_prob
            _lowerCAmelCase												=							attention_probs_dropout_prob
            _lowerCAmelCase												=							drop_path_rate
            _lowerCAmelCase												=							hidden_act
            _lowerCAmelCase												=							use_absolute_embeddings
            _lowerCAmelCase												=							layer_norm_eps
            _lowerCAmelCase												=							initializer_range
            _lowerCAmelCase												=							encoder_stride
            # we set the hidden_size attribute in order to make Swinv2 work with VisionEncoderDecoderModel
            # this indicates the channel dimension after the last stage of the model
            _lowerCAmelCase												=							int(embed_dim * 2 ** (len(__a  ) - 1)  )
            _lowerCAmelCase												=							(0, 0, 0, 0)













'''simple docstring'''






from manim import *




class 			UpperCAmelCase					(      snake_case_       ):




      def     lowercase__   (      self      :			Union[str, Any]  )    ->				str:
            _lowerCAmelCase												=							Rectangle(height=0.5      ,      width=0.5  )
            _lowerCAmelCase												=							Rectangle(height=0.46      ,      width=0.46  ).set_stroke(width=0  )

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

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

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

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

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

                  _lowerCAmelCase												=							Rectangle(height=0.46 / 4      ,      width=0.46 / 3  ).set_stroke(width=0.0  ).set_fill(__snake_case      ,      opacity=0.7  )

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

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

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

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

            _lowerCAmelCase												=							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(__snake_case      ,      __snake_case  )

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

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

            _lowerCAmelCase												=							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(__snake_case  )      ,      Write(__snake_case  )  )

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

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

                  _lowerCAmelCase												=							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(__snake_case      ,      run_time=1.5  )  )

            self.play(*__snake_case  )
            self.play(*__snake_case  )
            self.wait()






