'''simple docstring'''


from typing import List, Optional, Tuple, Union

import torch
from torch import nn
from torch.nn import CrossEntropyLoss

from ... import AutoBackbone
from ...modeling_outputs import SemanticSegmenterOutput
from ...modeling_utils import PreTrainedModel
from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
from ...utils.backbone_utils import BackboneMixin
from .configuration_upernet import UperNetConfig


snake_case__					:      Dict				      =  [
    '''openmmlab/upernet-convnext-tiny''',
    # See all UperNet models at https://huggingface.co/models?filter=upernet
]

# General docstring
snake_case__					:      List[str]				      =  '''UperNetConfig'''






class 					__SCREAMING_SNAKE_CASE						(	nn.Module	):







  '''simple docstring'''






  def __init__(			self				,		snake_case_				,		snake_case_				,		snake_case_				,		snake_case_ = 0				,		snake_case_ = False				,		snake_case_ = 1				,		):




       '''simple docstring'''

       super().__init__()
       UpperCAmelCase_							:       Dict       =				nn.Convad(
           in_channels=snake_case_				,		out_channels=snake_case_				,		kernel_size=snake_case_				,		padding=snake_case_				,		bias=snake_case_				,		dilation=snake_case_				,		)
       UpperCAmelCase_							:       Union[str, Any]       =				nn.BatchNormad(snake_case_						)
       UpperCAmelCase_							:       Union[str, Any]       =				nn.ReLU()






  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       List[Any]       =				self.conv(snake_case_						)
       UpperCAmelCase_							:       Tuple       =				self.batch_norm(snake_case_						)
       UpperCAmelCase_							:       str       =				self.activation(snake_case_						)

       return output







class 					__SCREAMING_SNAKE_CASE						(	nn.Module	):







  '''simple docstring'''






  def __init__(			self				,		snake_case_				,		snake_case_				,		snake_case_						):




       '''simple docstring'''

       super().__init__()
       UpperCAmelCase_							:       Tuple       =				[
           nn.AdaptiveAvgPoolad(snake_case_						),
           UperNetConvModule(snake_case_				,		snake_case_				,		kernel_size=1						),
       ]
       for i, layer in enumerate(self.layers						):
            self.add_module(str(snake_case_						)				,		snake_case_						)






  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       str       =				input
       for layer in self.layers:
            UpperCAmelCase_							:       Union[str, Any]       =				layer(snake_case_						)
       return hidden_state







class 					__SCREAMING_SNAKE_CASE						(	nn.Module	):







  '''simple docstring'''






  def __init__(			self				,		snake_case_				,		snake_case_				,		snake_case_				,		snake_case_						):




       '''simple docstring'''

       super().__init__()
       UpperCAmelCase_							:       Any       =				pool_scales
       UpperCAmelCase_							:       str       =				align_corners
       UpperCAmelCase_							:       List[Any]       =				in_channels
       UpperCAmelCase_							:       Optional[int]       =				channels
       UpperCAmelCase_							:       List[Any]       =				[]
       for i, pool_scale in enumerate(snake_case_						):
            UpperCAmelCase_							:       List[Any]       =				UperNetPyramidPoolingBlock(pool_scale=snake_case_				,		in_channels=snake_case_				,		channels=snake_case_						)
            self.blocks.append(snake_case_						)
            self.add_module(str(snake_case_						)				,		snake_case_						)






  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       Union[str, Any]       =				[]
       for ppm in self.blocks:
            UpperCAmelCase_							:       Union[str, Any]       =				ppm(snake_case_						)
            UpperCAmelCase_							:       Dict       =				nn.functional.interpolate(
                snake_case_				,		size=x.size()[2:]				,		mode='bilinear'				,		align_corners=self.align_corners						)
            ppm_outs.append(snake_case_						)
       return ppm_outs







class 					__SCREAMING_SNAKE_CASE						(	nn.Module	):







  '''simple docstring'''






  def __init__(			self				,		snake_case_				,		snake_case_						):




       '''simple docstring'''

       super().__init__()

       UpperCAmelCase_							:       List[str]       =				config
       UpperCAmelCase_							:       List[Any]       =				config.pool_scales  # e.g. (1, 2, 3, 6)
       UpperCAmelCase_							:       Dict       =				in_channels
       UpperCAmelCase_							:       int       =				config.hidden_size
       UpperCAmelCase_							:       Union[str, Any]       =				False
       UpperCAmelCase_							:       int       =				nn.Convad(self.channels				,		config.num_labels				,		kernel_size=1						)

       # PSP Module
       UpperCAmelCase_							:       int       =				UperNetPyramidPoolingModule(
           self.pool_scales				,		self.in_channels[-1]				,		self.channels				,		align_corners=self.align_corners				,		)
       UpperCAmelCase_							:       Union[str, Any]       =				UperNetConvModule(
           self.in_channels[-1] + len(self.pool_scales						) * self.channels				,		self.channels				,		kernel_size=3				,		padding=1				,		)
       # FPN Module
       UpperCAmelCase_							:       Tuple       =				nn.ModuleList()
       UpperCAmelCase_							:       Dict       =				nn.ModuleList()
       for in_channels in self.in_channels[:-1]:  # skip the top layer
            UpperCAmelCase_							:       Optional[Any]       =				UperNetConvModule(snake_case_				,		self.channels				,		kernel_size=1						)
            UpperCAmelCase_							:       str       =				UperNetConvModule(self.channels				,		self.channels				,		kernel_size=3				,		padding=1						)
            self.lateral_convs.append(snake_case_						)
            self.fpn_convs.append(snake_case_						)

       UpperCAmelCase_							:       int       =				UperNetConvModule(
           len(self.in_channels						) * self.channels				,		self.channels				,		kernel_size=3				,		padding=1				,		)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       self.apply(self._init_weights						)


  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       if isinstance(snake_case_				,		nn.Convad						):
            module.weight.data.normal_(mean=0.0				,		std=self.config.initializer_range						)
            if module.bias is not None:
                 module.bias.data.zero_()


  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       Optional[int]       =				inputs[-1]
       UpperCAmelCase_							:       Optional[Any]       =				[x]
       psp_outs.extend(self.psp_modules(snake_case_						)						)
       UpperCAmelCase_							:       Dict       =				torch.cat(snake_case_				,		dim=1						)
       UpperCAmelCase_							:       Dict       =				self.bottleneck(snake_case_						)

       return output






  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       Union[str, Any]       =				[lateral_conv(encoder_hidden_states[i]						) for i, lateral_conv in enumerate(self.lateral_convs						)]

       laterals.append(self.psp_forward(snake_case_						)						)

       # build top-down path
       UpperCAmelCase_							:       Optional[Any]       =				len(snake_case_						)
       for i in range(used_backbone_levels - 1				,		0				,		-1						):
            UpperCAmelCase_							:       List[str]       =				laterals[i - 1].shape[2:]
            UpperCAmelCase_							:       List[Any]       =				laterals[i - 1] + nn.functional.interpolate(
                laterals[i]				,		size=snake_case_				,		mode='bilinear'				,		align_corners=self.align_corners						)

       # build outputs
       UpperCAmelCase_							:       Dict       =				[self.fpn_convs[i](laterals[i]						) for i in range(used_backbone_levels - 1						)]
       # append psp feature
       fpn_outs.append(laterals[-1]						)

       for i in range(used_backbone_levels - 1				,		0				,		-1						):
            UpperCAmelCase_							:       Any       =				nn.functional.interpolate(
                fpn_outs[i]				,		size=fpn_outs[0].shape[2:]				,		mode='bilinear'				,		align_corners=self.align_corners						)
       UpperCAmelCase_							:       Optional[Any]       =				torch.cat(snake_case_				,		dim=1						)
       UpperCAmelCase_							:       int       =				self.fpn_bottleneck(snake_case_						)
       UpperCAmelCase_							:       List[str]       =				self.classifier(snake_case_						)

       return output







class 					__SCREAMING_SNAKE_CASE						(	nn.Module	):







  '''simple docstring'''






  def __init__(			self				,		snake_case_				,		snake_case_ = 2				,		snake_case_ = 3				,		snake_case_ = 1						):




       '''simple docstring'''

       super().__init__()

       UpperCAmelCase_							:       List[str]       =				config
       UpperCAmelCase_							:       Dict       =				config.auxiliary_in_channels
       UpperCAmelCase_							:       Union[str, Any]       =				config.auxiliary_channels
       UpperCAmelCase_							:       List[Any]       =				config.auxiliary_num_convs
       UpperCAmelCase_							:       Union[str, Any]       =				config.auxiliary_concat_input
       UpperCAmelCase_							:       Union[str, Any]       =				in_index

       UpperCAmelCase_							:       List[str]       =				(kernel_size // 2) * dilation
       UpperCAmelCase_							:       Dict       =				[]
       convs.append(
           UperNetConvModule(
               self.in_channels				,		self.channels				,		kernel_size=snake_case_				,		padding=snake_case_				,		dilation=snake_case_						)						)
       for i in range(self.num_convs - 1						):
            convs.append(
                UperNetConvModule(
                    self.channels				,		self.channels				,		kernel_size=snake_case_				,		padding=snake_case_				,		dilation=snake_case_						)						)
       if self.num_convs == 0:
            UpperCAmelCase_							:       List[Any]       =				nn.Identity()
       else:
            UpperCAmelCase_							:       Any       =				nn.Sequential(*snake_case_						)
       if self.concat_input:
            UpperCAmelCase_							:       Tuple       =				UperNetConvModule(
                self.in_channels + self.channels				,		self.channels				,		kernel_size=snake_case_				,		padding=kernel_size // 2						)

       UpperCAmelCase_							:       List[str]       =				nn.Convad(self.channels				,		config.num_labels				,		kernel_size=1						)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       self.apply(self._init_weights						)


  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       if isinstance(snake_case_				,		nn.Convad						):
            module.weight.data.normal_(mean=0.0				,		std=self.config.initializer_range						)
            if module.bias is not None:
                 module.bias.data.zero_()






  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       Union[str, Any]       =				encoder_hidden_states[self.in_index]
       UpperCAmelCase_							:       Union[str, Any]       =				self.convs(snake_case_						)
       if self.concat_input:
            UpperCAmelCase_							:       List[str]       =				self.conv_cat(torch.cat([hidden_states, output]				,		dim=1						)						)
       UpperCAmelCase_							:       Optional[Any]       =				self.classifier(snake_case_						)
       return output







class 					__SCREAMING_SNAKE_CASE						(	lowerCamelCase_	):







  '''simple docstring'''






  lowerCamelCase_		:List[Any]						   =		UperNetConfig
  lowerCamelCase_		:int						   =		'''pixel_values'''
  lowerCamelCase_		:Optional[Any]						   =		True


  def _UpperCamelCase					(			self				,		snake_case_						):




       '''simple docstring'''

       if isinstance(snake_case_				,		snake_case_						):
            module.backbone.init_weights()
            module.decode_head.init_weights()
            module.auxiliary_head.init_weights()


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       self.backbone.init_weights()
       self.decode_head.init_weights()
       self.auxiliary_head.init_weights()






  def _UpperCamelCase					(			self				,		snake_case_				,		snake_case_=False						):




       '''simple docstring'''

       if isinstance(snake_case_				,		snake_case_						):
            UpperCAmelCase_							:       Tuple       =				value







snake_case__					:      List[str]				      =  r'''
    Parameters:
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
    it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.
        config ([`UperNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
'''

snake_case__					:      int				      =  r'''
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Padding will be ignored by default should you provide it. Pixel values can be obtained using
            [`AutoImageProcessor`]. See [`SegformerImageProcessor.__call__`] for details.
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers in case the backbone has them. See
            `attentions` under returned tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers of the backbone. See `hidden_states` under
            returned tensors for more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
'''






@add_start_docstrings(
    '''UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes.'''						,     lowerCamelCase_						,     )
class 					__SCREAMING_SNAKE_CASE						(	lowerCamelCase_	):







  '''simple docstring'''






  def __init__(			self				,		snake_case_						):




       '''simple docstring'''

       super().__init__(snake_case_						)

       UpperCAmelCase_							:       List[str]       =				AutoBackbone.from_config(config.backbone_config						)

       # Semantic segmentation head(s)
       UpperCAmelCase_							:       Optional[Any]       =				UperNetHead(snake_case_				,		in_channels=self.backbone.channels						)
       UpperCAmelCase_							:       int       =				UperNetFCNHead(snake_case_						) if config.use_auxiliary_head else None

       # Initialize weights and apply final processing
       self.post_init()






  @add_start_docstrings_to_model_forward(UPERNET_INPUTS_DOCSTRING.format('batch_size, sequence_length'						)						)
  @replace_return_docstrings(output_type=snake_case_				,		config_class=_CONFIG_FOR_DOC						)
  def _UpperCamelCase					(			self				,		snake_case_ = None				,		snake_case_ = None				,		snake_case_ = None				,		snake_case_ = None				,		snake_case_ = None				,		):




       '''simple docstring'''

       UpperCAmelCase_							:       Dict       =				return_dict if return_dict is not None else self.config.use_return_dict
       UpperCAmelCase_							:       List[str]       =				(
           output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
       )
       UpperCAmelCase_							:       Tuple       =				output_attentions if output_attentions is not None else self.config.output_attentions

       UpperCAmelCase_							:       List[Any]       =				self.backbone.forward_with_filtered_kwargs(
           snake_case_				,		output_hidden_states=snake_case_				,		output_attentions=snake_case_						)
       UpperCAmelCase_							:       str       =				outputs.feature_maps

       UpperCAmelCase_							:       Union[str, Any]       =				self.decode_head(snake_case_						)
       UpperCAmelCase_							:       Dict       =				nn.functional.interpolate(snake_case_				,		size=pixel_values.shape[2:]				,		mode='bilinear'				,		align_corners=snake_case_						)

       UpperCAmelCase_							:       List[str]       =				None
       if self.auxiliary_head is not None:
            UpperCAmelCase_							:       Optional[int]       =				self.auxiliary_head(snake_case_						)
            UpperCAmelCase_							:       Tuple       =				nn.functional.interpolate(
                snake_case_				,		size=pixel_values.shape[2:]				,		mode='bilinear'				,		align_corners=snake_case_						)

       UpperCAmelCase_							:       Union[str, Any]       =				None
       if labels is not None:
            if self.config.num_labels == 1:
                 raise ValueError('The number of labels should be greater than one'						)
            else:
                 # compute weighted loss
                 UpperCAmelCase_							:       List[str]       =				CrossEntropyLoss(ignore_index=self.config.loss_ignore_index						)
                 UpperCAmelCase_							:       List[str]       =				loss_fct(snake_case_				,		snake_case_						)
                 UpperCAmelCase_							:       Optional[int]       =				loss_fct(snake_case_				,		snake_case_						)
                 UpperCAmelCase_							:       List[Any]       =				main_loss + self.config.auxiliary_loss_weight * auxiliary_loss

       if not return_dict:
            if output_hidden_states:
                 UpperCAmelCase_							:       Optional[int]       =				(logits,) + outputs[1:]
            else:
                 UpperCAmelCase_							:       str       =				(logits,) + outputs[2:]
            return ((loss,) + output) if loss is not None else output

       return SemanticSegmenterOutput(
           loss=snake_case_				,		logits=snake_case_				,		hidden_states=outputs.hidden_states				,		attentions=outputs.attentions				,		)







'''simple docstring'''


from manim import *






class 					__SCREAMING_SNAKE_CASE						(	lowerCamelCase_	):







  '''simple docstring'''






  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       Dict       =				Rectangle(height=0.5				,		width=0.5						)
       UpperCAmelCase_							:       Any       =				Rectangle(height=0.46				,		width=0.46						).set_stroke(width=0						)

       UpperCAmelCase_							:       List[str]       =				Rectangle(height=0.25				,		width=0.25						)

       UpperCAmelCase_							:       Any       =				[mem.copy() for i in range(6						)]
       UpperCAmelCase_							:       Union[str, Any]       =				[mem.copy() for i in range(6						)]
       UpperCAmelCase_							:       Optional[int]       =				VGroup(*snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       Any       =				VGroup(*snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       str       =				VGroup(snake_case_				,		snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       Any       =				Text('CPU'				,		font_size=2_4						)
       UpperCAmelCase_							:       Tuple       =				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_						)

       UpperCAmelCase_							:       str       =				[mem.copy() for i in range(4						)]
       UpperCAmelCase_							:       Dict       =				VGroup(*snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       List[str]       =				Text('GPU'				,		font_size=2_4						)
       UpperCAmelCase_							:       Optional[int]       =				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_						)

       UpperCAmelCase_							:       str       =				[mem.copy() for i in range(6						)]
       UpperCAmelCase_							:       Tuple       =				VGroup(*snake_case_						).arrange(snake_case_				,		buff=0						)

       UpperCAmelCase_							:       str       =				Text('Model'				,		font_size=2_4						)
       UpperCAmelCase_							:       Optional[int]       =				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_						)

       UpperCAmelCase_							:       str       =				[]
       UpperCAmelCase_							:       Optional[Any]       =				[]

       for i, rect in enumerate(snake_case_						):
            UpperCAmelCase_							:       str       =				fill.copy().set_fill(snake_case_				,		opacity=0.8						)
            target.move_to(snake_case_						)
            model_arr.append(snake_case_						)

            UpperCAmelCase_							:       int       =				Rectangle(height=0.46				,		width=0.46						).set_stroke(width=0.0						).set_fill(snake_case_				,		opacity=0.8						)
            cpu_target.move_to(cpu_left_col_base[i]						)
            model_cpu_arr.append(snake_case_						)

       self.add(*snake_case_				,		*snake_case_						)

       UpperCAmelCase_							:       List[Any]       =				[meta_mem.copy() for i in range(6						)]
       UpperCAmelCase_							:       List[str]       =				[meta_mem.copy() for i in range(6						)]
       UpperCAmelCase_							:       Tuple       =				VGroup(*snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       Dict       =				VGroup(*snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       Optional[Any]       =				VGroup(snake_case_				,		snake_case_						).arrange(snake_case_				,		buff=0						)
       UpperCAmelCase_							:       Tuple       =				Text('Disk'				,		font_size=2_4						)
       UpperCAmelCase_							:       Union[str, Any]       =				Group(snake_case_				,		snake_case_						).arrange(snake_case_				,		buff=0.5				,		aligned_edge=snake_case_						)
       disk.move_to([-4, -1.25, 0]						)
       self.add(snake_case_				,		snake_case_						)

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

       UpperCAmelCase_							:       Any       =				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(snake_case_				,		snake_case_						)

       UpperCAmelCase_							:       Dict       =				MarkupText(
           F'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''				,		font_size=1_8				,		)

       blue_text.next_to(snake_case_				,		DOWN * 2.4				,		aligned_edge=key_text.get_left()						)
       self.add(snake_case_						)

       UpperCAmelCase_							:       Optional[Any]       =				MarkupText(
           F'''Now watch as an input is passed through the model\nand how the memory is utilized and handled.'''				,		font_size=2_4				,		)
       step_a.move_to([2, 2, 0]						)

       self.play(Write(snake_case_						)						)

       UpperCAmelCase_							:       Tuple       =				Square(0.3						)
       input.set_fill(snake_case_				,		opacity=1.0						)
       input.set_stroke(width=0.0						)
       input.next_to(model_base[0]				,		snake_case_				,		buff=0.5						)

       self.play(Write(snake_case_						)						)

       input.generate_target()
       input.target.next_to(model_arr[0]				,		direction=snake_case_				,		buff=0.02						)
       self.play(MoveToTarget(snake_case_						)						)

       self.play(FadeOut(snake_case_						)						)

       UpperCAmelCase_							:       Any       =				Arrow(start=snake_case_				,		end=snake_case_				,		color=snake_case_				,		buff=0.5						)
       a.next_to(model_arr[0].get_left()				,		snake_case_				,		buff=0.2						)

       model_cpu_arr[0].generate_target()
       model_cpu_arr[0].target.move_to(gpu_rect[0]						)

       UpperCAmelCase_							:       List[str]       =				MarkupText(
           F'''As the input reaches a layer, the hook triggers\nand weights are moved from the CPU\nto the GPU and back.'''				,		font_size=2_4				,		)
       step_a.move_to([2, 2, 0]						)

       self.play(Write(snake_case_				,		run_time=3						)						)

       UpperCAmelCase_							:       List[Any]       =				{'run_time': 1, 'fade_in': True, 'fade_out': True, 'buff': 0.02}

       self.play(
           Write(snake_case_						)				,		Circumscribe(model_arr[0]				,		color=snake_case_				,		**snake_case_						)				,		Circumscribe(model_cpu_arr[0]				,		color=snake_case_				,		**snake_case_						)				,		Circumscribe(gpu_rect[0]				,		color=snake_case_				,		**snake_case_						)				,		)
       self.play(MoveToTarget(model_cpu_arr[0]						)						)

       UpperCAmelCase_							:       Union[str, Any]       =				a.copy()
       for i in range(6						):
            a_c.next_to(model_arr[i].get_right() + 0.02				,		snake_case_				,		buff=0.2						)

            input.generate_target()
            input.target.move_to(model_arr[i].get_right() + 0.02						)

            UpperCAmelCase_							:       Tuple       =				AnimationGroup(
                FadeOut(snake_case_				,		run_time=0.5						)				,		MoveToTarget(snake_case_				,		run_time=0.5						)				,		FadeIn(snake_case_				,		run_time=0.5						)				,		lag_ratio=0.2						)

            self.play(snake_case_						)

            model_cpu_arr[i].generate_target()
            model_cpu_arr[i].target.move_to(cpu_left_col_base[i]						)

            if i < 5:
                 model_cpu_arr[i + 1].generate_target()
                 model_cpu_arr[i + 1].target.move_to(gpu_rect[0]						)
                 if i >= 1:
                      UpperCAmelCase_							:       Any       =				0.7

                 self.play(
                     Circumscribe(model_arr[i]				,		**snake_case_						)				,		Circumscribe(cpu_left_col_base[i]				,		**snake_case_						)				,		Circumscribe(cpu_left_col_base[i + 1]				,		color=snake_case_				,		**snake_case_						)				,		Circumscribe(gpu_rect[0]				,		color=snake_case_				,		**snake_case_						)				,		Circumscribe(model_arr[i + 1]				,		color=snake_case_				,		**snake_case_						)				,		)
                 if i < 1:
                      self.play(
                          MoveToTarget(model_cpu_arr[i]						)				,		MoveToTarget(model_cpu_arr[i + 1]						)				,		)
                 else:
                      self.play(
                          MoveToTarget(model_cpu_arr[i]				,		run_time=0.7						)				,		MoveToTarget(model_cpu_arr[i + 1]				,		run_time=0.7						)				,		)
            else:
                 model_cpu_arr[i].generate_target()
                 model_cpu_arr[i].target.move_to(cpu_left_col_base[-1]						)
                 input.generate_target()
                 input.target.next_to(model_arr[-1].get_right()				,		RIGHT + 0.02				,		buff=0.2						)

                 self.play(
                     Circumscribe(model_arr[-1]				,		color=snake_case_				,		**snake_case_						)				,		Circumscribe(cpu_left_col_base[-1]				,		color=snake_case_				,		**snake_case_						)				,		Circumscribe(gpu_rect[0]				,		color=snake_case_				,		**snake_case_						)				,		)

                 self.play(MoveToTarget(model_cpu_arr[i]						)						)

            UpperCAmelCase_							:       Any       =				a_c
            UpperCAmelCase_							:       int       =				a_c.copy()

       input.generate_target()
       input.target.next_to(model_base[-1]				,		RIGHT + 0.02				,		buff=0.5						)
       self.play(
           FadeOut(snake_case_						)				,		FadeOut(snake_case_				,		run_time=0.5						)				,		)

       UpperCAmelCase_							:       Optional[Any]       =				MarkupText(F'''Inference on a model too large for GPU memory\nis successfully completed.'''				,		font_size=2_4						)
       step_a.move_to([2, 2, 0]						)

       self.play(Write(snake_case_				,		run_time=3						)				,		MoveToTarget(snake_case_						)						)

       self.wait()






