'''simple docstring'''




from __future__ import annotations

import os
import tempfile
import unittest

from transformers import ConvBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
  import tensorflow as tf

  from transformers import (
      TFConvBertForMaskedLM,
      TFConvBertForMultipleChoice,
      TFConvBertForQuestionAnswering,
      TFConvBertForSequenceClassification,
      TFConvBertForTokenClassification,
      TFConvBertModel,
  )




class        a__ :






     def __init__(					self						:						str    ,							a						:						Optional[Any]    ,							a						:						List[Any]=13    ,							a						:						List[Any]=7    ,							a						:						Optional[int]=True    ,							a						:						int=True    ,							a						:						Tuple=True    ,							a						:						Union[str, Any]=True    ,							a						:						Union[str, Any]=99    ,							a						:						Dict=32    ,							a						:						Dict=2    ,							a						:						str=4    ,							a						:						Any=37    ,							a						:						Optional[Any]="gelu"    ,							a						:						Tuple=0.1    ,							a						:						Tuple=0.1    ,							a						:						str=5_12    ,							a						:						str=16    ,							a						:						Optional[Any]=2    ,							a						:						Optional[Any]=0.02    ,							a						:						Optional[Any]=3    ,							a						:						int=4    ,							a						:						Union[str, Any]=None    ,							):





         """simple docstring"""



         __lowerCamelCase            =    parent
         __lowerCamelCase            =    13
         __lowerCamelCase            =    7
         __lowerCamelCase            =    True
         __lowerCamelCase            =    True
         __lowerCamelCase            =    True
         __lowerCamelCase            =    True
         __lowerCamelCase            =    99
         __lowerCamelCase            =    3_84
         __lowerCamelCase            =    2
         __lowerCamelCase            =    4
         __lowerCamelCase            =    37
         __lowerCamelCase            =    '''gelu'''
         __lowerCamelCase            =    0.1
         __lowerCamelCase            =    0.1
         __lowerCamelCase            =    5_12
         __lowerCamelCase            =    16
         __lowerCamelCase            =    2
         __lowerCamelCase            =    0.02
         __lowerCamelCase            =    3
         __lowerCamelCase            =    4
         __lowerCamelCase            =    1_28
         __lowerCamelCase            =    2
         __lowerCamelCase            =    9
         __lowerCamelCase            =    1
         __lowerCamelCase            =    None






     def   SCREAMING_SNAKE_CASE__  (					self						:						int       ):





         """simple docstring"""



         __lowerCamelCase            =    ids_tensor([self.batch_size, self.seq_length]    ,							self.vocab_size       )

         __lowerCamelCase            =    None
         if self.use_input_mask:
             __lowerCamelCase            =    random_attention_mask([self.batch_size, self.seq_length]       )

         __lowerCamelCase            =    None
         if self.use_token_type_ids:
             __lowerCamelCase            =    ids_tensor([self.batch_size, self.seq_length]    ,							self.type_vocab_size       )

         __lowerCamelCase            =    None
         __lowerCamelCase            =    None
         __lowerCamelCase            =    None
         if self.use_labels:
             __lowerCamelCase            =    ids_tensor([self.batch_size]    ,							self.type_sequence_label_size       )
             __lowerCamelCase            =    ids_tensor([self.batch_size, self.seq_length]    ,							self.num_labels       )
             __lowerCamelCase            =    ids_tensor([self.batch_size]    ,							self.num_choices       )

         __lowerCamelCase            =    ConvBertConfig(
             vocab_size=self.vocab_size    ,							hidden_size=self.hidden_size    ,							num_hidden_layers=self.num_hidden_layers    ,							num_attention_heads=self.num_attention_heads    ,							intermediate_size=self.intermediate_size    ,							hidden_act=self.hidden_act    ,							hidden_dropout_prob=self.hidden_dropout_prob    ,							attention_probs_dropout_prob=self.attention_probs_dropout_prob    ,							max_position_embeddings=self.max_position_embeddings    ,							type_vocab_size=self.type_vocab_size    ,							initializer_range=self.initializer_range    ,							return_dict=a    ,							)

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels






     def   SCREAMING_SNAKE_CASE__  (					self						:						List[Any]    ,							a						:						Optional[Any]    ,							a						:						Optional[Any]    ,							a						:						str    ,							a						:						Union[str, Any]    ,							a						:						List[Any]    ,							a						:						Union[str, Any]    ,							a						:						List[str]       ):





         """simple docstring"""



         __lowerCamelCase            =    TFConvBertModel(config=a       )
         __lowerCamelCase            =    {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

         __lowerCamelCase            =    [input_ids, input_mask]
         __lowerCamelCase            =    model(a       )

         __lowerCamelCase            =    model(a       )

         self.parent.assertEqual(result.last_hidden_state.shape    ,							(self.batch_size, self.seq_length, self.hidden_size)       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Optional[int]    ,							a						:						Optional[Any]    ,							a						:						Optional[int]    ,							a						:						Any    ,							a						:						Tuple    ,							a						:						Any    ,							a						:						Tuple    ,							a						:						int       ):





         """simple docstring"""



         __lowerCamelCase            =    TFConvBertForMaskedLM(config=a       )
         __lowerCamelCase            =    {
             '''input_ids''': input_ids,
             '''attention_mask''': input_mask,
             '''token_type_ids''': token_type_ids,
         }
         __lowerCamelCase            =    model(a       )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.seq_length, self.vocab_size)       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						int    ,							a						:						Any    ,							a						:						Optional[Any]    ,							a						:						Tuple    ,							a						:						Optional[Any]    ,							a						:						Optional[Any]    ,							a						:						Any    ,							a						:						str       ):





         """simple docstring"""



         __lowerCamelCase            =    self.num_labels
         __lowerCamelCase            =    TFConvBertForSequenceClassification(config=a       )
         __lowerCamelCase            =    {
             '''input_ids''': input_ids,
             '''attention_mask''': input_mask,
             '''token_type_ids''': token_type_ids,
         }

         __lowerCamelCase            =    model(a       )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.num_labels)       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Optional[Any]    ,							a						:						Union[str, Any]    ,							a						:						Union[str, Any]    ,							a						:						int    ,							a						:						Union[str, Any]    ,							a						:						Optional[int]    ,							a						:						Tuple    ,							a						:						List[str]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.num_choices
         __lowerCamelCase            =    TFConvBertForMultipleChoice(config=a       )
         __lowerCamelCase            =    tf.tile(tf.expand_dims(a    ,							1       )    ,							(1, self.num_choices, 1)       )
         __lowerCamelCase            =    tf.tile(tf.expand_dims(a    ,							1       )    ,							(1, self.num_choices, 1)       )
         __lowerCamelCase            =    tf.tile(tf.expand_dims(a    ,							1       )    ,							(1, self.num_choices, 1)       )
         __lowerCamelCase            =    {
             '''input_ids''': multiple_choice_inputs_ids,
             '''attention_mask''': multiple_choice_input_mask,
             '''token_type_ids''': multiple_choice_token_type_ids,
         }
         __lowerCamelCase            =    model(a       )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.num_choices)       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Dict    ,							a						:						Optional[Any]    ,							a						:						Optional[Any]    ,							a						:						Optional[int]    ,							a						:						List[str]    ,							a						:						str    ,							a						:						str    ,							a						:						Union[str, Any]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.num_labels
         __lowerCamelCase            =    TFConvBertForTokenClassification(config=a       )
         __lowerCamelCase            =    {
             '''input_ids''': input_ids,
             '''attention_mask''': input_mask,
             '''token_type_ids''': token_type_ids,
         }
         __lowerCamelCase            =    model(a       )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.seq_length, self.num_labels)       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						List[str]    ,							a						:						Dict    ,							a						:						List[Any]    ,							a						:						Union[str, Any]    ,							a						:						Any    ,							a						:						Tuple    ,							a						:						Dict    ,							a						:						str       ):





         """simple docstring"""



         __lowerCamelCase            =    TFConvBertForQuestionAnswering(config=a       )
         __lowerCamelCase            =    {
             '''input_ids''': input_ids,
             '''attention_mask''': input_mask,
             '''token_type_ids''': token_type_ids,
         }

         __lowerCamelCase            =    model(a       )
         self.parent.assertEqual(result.start_logits.shape    ,							(self.batch_size, self.seq_length)       )
         self.parent.assertEqual(result.end_logits.shape    ,							(self.batch_size, self.seq_length)       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Tuple       ):





         """simple docstring"""



         __lowerCamelCase            =    self.prepare_config_and_inputs()
         (
             (
             __lowerCamelCase
         )      ,    (
             __lowerCamelCase
         )      ,    (
             __lowerCamelCase
         )      ,    (
             __lowerCamelCase
         )      ,    (
             __lowerCamelCase
         )      ,    (
             __lowerCamelCase
         )      ,    (
             __lowerCamelCase
         )      ,    
         )            =    config_and_inputs
         __lowerCamelCase            =    {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
         return config, inputs_dict




@require_tf
class        a__ (  UpperCAmelCase__				,  UpperCAmelCase__				,  unittest.TestCase					):
     lowerCamelCase    :	Any				=(
         (
             TFConvBertModel,
             TFConvBertForMaskedLM,
             TFConvBertForQuestionAnswering,
             TFConvBertForSequenceClassification,
             TFConvBertForTokenClassification,
             TFConvBertForMultipleChoice,
         )
         if is_tf_available()
         else ()
     )
     lowerCamelCase    :	Optional[int]				=(
         {
             "feature-extraction": TFConvBertModel,
             "fill-mask": TFConvBertForMaskedLM,
             "question-answering": TFConvBertForQuestionAnswering,
             "text-classification": TFConvBertForSequenceClassification,
             "token-classification": TFConvBertForTokenClassification,
             "zero-shot": TFConvBertForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )
     lowerCamelCase    :	List[Any]				=False
     lowerCamelCase    :	Dict				=False
     lowerCamelCase    :	Any				=False






     def   SCREAMING_SNAKE_CASE__  (					self						:						Tuple       ):





         """simple docstring"""



         __lowerCamelCase            =    TFConvBertModelTester(self       )
         __lowerCamelCase            =    ConfigTester(self    ,							config_class=a    ,							hidden_size=37       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						str       ):





         """simple docstring"""



         self.config_tester.run_common_tests()






     def   SCREAMING_SNAKE_CASE__  (					self						:						Tuple       ):





         """simple docstring"""



         __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*a       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						List[str]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_lm(*a       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						List[str]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_multiple_choice(*a       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Union[str, Any]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*a       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						str       ):





         """simple docstring"""



         __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*a       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						List[str]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*a       )






     @slow
     def   SCREAMING_SNAKE_CASE__  (					self						:						List[Any]       ):





         """simple docstring"""



         __lowerCamelCase      ,    __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs_for_common()
         __lowerCamelCase            =    True
         __lowerCamelCase            =    True

         if hasattr(a    ,							'''use_cache'''       ):
             __lowerCamelCase            =    True

         __lowerCamelCase            =    getattr(self.model_tester    ,							'''encoder_seq_length'''    ,							self.model_tester.seq_length       )
         __lowerCamelCase            =    getattr(self.model_tester    ,							'''key_length'''    ,							a       )

         for model_class in self.all_model_classes:
             __lowerCamelCase            =    self._prepare_for_class(a    ,							a       )
             __lowerCamelCase            =    model_class(a       )
             __lowerCamelCase            =    len(model(a       )       )

             with tempfile.TemporaryDirectory() as tmpdirname:
                 model.save_pretrained(a    ,							saved_model=a       )
                 __lowerCamelCase            =    os.path.join(a    ,							'''saved_model'''    ,							'''1'''       )
                 __lowerCamelCase            =    tf.keras.models.load_model(a       )
                 __lowerCamelCase            =    model(a       )

                 if self.is_encoder_decoder:
                     __lowerCamelCase            =    outputs['''encoder_hidden_states''']
                     __lowerCamelCase            =    outputs['''encoder_attentions''']
                 else:
                     __lowerCamelCase            =    outputs['''hidden_states''']
                     __lowerCamelCase            =    outputs['''attentions''']

                 self.assertEqual(len(a       )    ,							a       )

                 __lowerCamelCase            =    getattr(
                     self.model_tester    ,							'''expected_num_hidden_layers'''    ,							self.model_tester.num_hidden_layers + 1       )

                 self.assertEqual(len(a       )    ,							a       )
                 self.assertListEqual(
                     list(output_hidden_states[0].shape[-2:]       )    ,							[self.model_tester.seq_length, self.model_tester.hidden_size]    ,							)

                 self.assertEqual(len(a       )    ,							self.model_tester.num_hidden_layers       )
                 self.assertListEqual(
                     list(output_attentions[0].shape[-3:]       )    ,							[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]    ,							)






     @slow
     def   SCREAMING_SNAKE_CASE__  (					self						:						List[Any]       ):





         """simple docstring"""



         __lowerCamelCase            =    TFConvBertModel.from_pretrained('''YituTech/conv-bert-base'''       )
         self.assertIsNotNone(a       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Optional[int]       ):





         """simple docstring"""



         __lowerCamelCase      ,    __lowerCamelCase            =    self.model_tester.prepare_config_and_inputs_for_common()
         __lowerCamelCase            =    True
         __lowerCamelCase            =    getattr(self.model_tester    ,							'''decoder_seq_length'''    ,							self.model_tester.seq_length       )
         __lowerCamelCase            =    getattr(self.model_tester    ,							'''encoder_seq_length'''    ,							self.model_tester.seq_length       )
         __lowerCamelCase            =    getattr(self.model_tester    ,							'''key_length'''    ,							a       )
         __lowerCamelCase            =    getattr(self.model_tester    ,							'''key_length'''    ,							a       )

         def check_decoder_attentions_output(a						:						Dict       ):
             __lowerCamelCase            =    len(a       )
             self.assertEqual(out_len % 2    ,							0       )
             __lowerCamelCase            =    outputs.decoder_attentions
             self.assertEqual(len(a       )    ,							self.model_tester.num_hidden_layers       )
             self.assertListEqual(
                 list(decoder_attentions[0].shape[-3:]       )    ,							[self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]    ,							)

         def check_encoder_attentions_output(a						:						int       ):
             __lowerCamelCase            =    [
                 t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
             ]
             self.assertEqual(len(a       )    ,							self.model_tester.num_hidden_layers       )
             self.assertListEqual(
                 list(attentions[0].shape[-3:]       )    ,							[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]    ,							)

         for model_class in self.all_model_classes:
             __lowerCamelCase            =    True
             __lowerCamelCase            =    False
             __lowerCamelCase            =    model_class(a       )
             __lowerCamelCase            =    model(self._prepare_for_class(a    ,							a       )       )
             __lowerCamelCase            =    len(a       )
             self.assertEqual(config.output_hidden_states    ,							a       )
             check_encoder_attentions_output(a       )

             if self.is_encoder_decoder:
                 __lowerCamelCase            =    model_class(a       )
                 __lowerCamelCase            =    model(self._prepare_for_class(a    ,							a       )       )
                 self.assertEqual(config.output_hidden_states    ,							a       )
                 check_decoder_attentions_output(a       )

             # Check that output attentions can also be changed via the config
             del inputs_dict["output_attentions"]
             __lowerCamelCase            =    True
             __lowerCamelCase            =    model_class(a       )
             __lowerCamelCase            =    model(self._prepare_for_class(a    ,							a       )       )
             self.assertEqual(config.output_hidden_states    ,							a       )
             check_encoder_attentions_output(a       )

             # Check attention is always last and order is fine
             __lowerCamelCase            =    True
             __lowerCamelCase            =    True
             __lowerCamelCase            =    model_class(a       )
             __lowerCamelCase            =    model(self._prepare_for_class(a    ,							a       )       )

             self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)    ,							len(a       )       )
             self.assertEqual(model.config.output_hidden_states    ,							a       )
             check_encoder_attentions_output(a       )




@require_tf
class        a__ (  unittest.TestCase					):






     @slow
     def   SCREAMING_SNAKE_CASE__  (					self						:						str       ):





         """simple docstring"""



         __lowerCamelCase            =    TFConvBertModel.from_pretrained('''YituTech/conv-bert-base'''       )
         __lowerCamelCase            =    tf.constant([[0, 1, 2, 3, 4, 5]]       )
         __lowerCamelCase            =    model(a       )[0]

         __lowerCamelCase            =    [1, 6, 7_68]
         self.assertEqual(output.shape    ,							a       )

         __lowerCamelCase            =    tf.constant(
             [
                 [
                     [-0.03_47_54_93, -0.4_68_60_34, -0.30_63_88_32],
                     [0.22_63_72_48, -0.26_98_86_46, -0.7_42_34_24],
                     [0.10_32_48_68, -0.45_01_35_08, -0.58_28_07_84],
                 ]
             ]       )
         tf.debugging.assert_near(output[:, :3, :3]    ,							a    ,							atol=1e-4       )

'''simple docstring'''




from manim import *




class        a__ (  UpperCAmelCase__					):






     def   SCREAMING_SNAKE_CASE__  (					self						:						List[Any]       ):





         """simple docstring"""



         __lowerCamelCase            =    Rectangle(height=0.5    ,							width=0.5       )
         __lowerCamelCase            =    Rectangle(height=0.46    ,							width=0.46       ).set_stroke(width=0       )

         __lowerCamelCase            =    Rectangle(height=0.25    ,							width=0.25       )

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

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

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

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

         __lowerCamelCase            =    []
         __lowerCamelCase            =    []

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

             __lowerCamelCase            =    Rectangle(height=0.46    ,							width=0.46       ).set_stroke(width=0.0       ).set_fill(a    ,							opacity=0.8       )
             cpu_target.move_to(cpu_left_col_base[i]       )
             model_cpu_arr.append(a       )

         self.add(*a    ,							*a       )

         __lowerCamelCase            =    [meta_mem.copy() for i in range(6       )]
         __lowerCamelCase            =    [meta_mem.copy() for i in range(6       )]
         __lowerCamelCase            =    VGroup(*a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    VGroup(*a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    VGroup(a    ,							a       ).arrange(a    ,							buff=0       )
         __lowerCamelCase            =    Text('''Disk'''    ,							font_size=24       )
         __lowerCamelCase            =    Group(a    ,							a       ).arrange(a    ,							buff=0.5    ,							aligned_edge=a       )
         disk.move_to([-4, -1.25, 0]       )
         self.add(a    ,							a       )

         __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(a    ,							a       )

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

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

         __lowerCamelCase            =    MarkupText(
             f"""Now watch as an input is passed through the model\nand how the memory is utilized and handled."""    ,							font_size=24    ,							)
         step_a.move_to([2, 2, 0]       )

         self.play(Write(a       )       )

         __lowerCamelCase            =    Square(0.3       )
         input.set_fill(a    ,							opacity=1.0       )
         input.set_stroke(width=0.0       )
         input.next_to(model_base[0]    ,							a    ,							buff=0.5       )

         self.play(Write(a       )       )

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

         self.play(FadeOut(a       )       )

         __lowerCamelCase            =    Arrow(start=a    ,							end=a    ,							color=a    ,							buff=0.5       )
         a.next_to(model_arr[0].get_left()    ,							a    ,							buff=0.2       )

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

         __lowerCamelCase            =    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=24    ,							)
         step_a.move_to([2, 2, 0]       )

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

         __lowerCamelCase            =    {'''run_time''': 1, '''fade_in''': True, '''fade_out''': True, '''buff''': 0.02}

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

         __lowerCamelCase            =    a.copy()
         for i in range(6       ):
             a_c.next_to(model_arr[i].get_right() + 0.02    ,							a    ,							buff=0.2       )

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

             __lowerCamelCase            =    AnimationGroup(
                 FadeOut(a    ,							run_time=0.5       )    ,							MoveToTarget(a    ,							run_time=0.5       )    ,							FadeIn(a    ,							run_time=0.5       )    ,							lag_ratio=0.2       )

             self.play(a       )

             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:
                     __lowerCamelCase            =    0.7

                 self.play(
                     Circumscribe(model_arr[i]    ,							**a       )    ,							Circumscribe(cpu_left_col_base[i]    ,							**a       )    ,							Circumscribe(cpu_left_col_base[i + 1]    ,							color=a    ,							**a       )    ,							Circumscribe(gpu_rect[0]    ,							color=a    ,							**a       )    ,							Circumscribe(model_arr[i + 1]    ,							color=a    ,							**a       )    ,							)
                 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=a    ,							**a       )    ,							Circumscribe(cpu_left_col_base[-1]    ,							color=a    ,							**a       )    ,							Circumscribe(gpu_rect[0]    ,							color=a    ,							**a       )    ,							)

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

             __lowerCamelCase            =    a_c
             __lowerCamelCase            =    a_c.copy()

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

         __lowerCamelCase            =    MarkupText(f"""Inference on a model too large for GPU memory\nis successfully completed."""    ,							font_size=24       )
         step_a.move_to([2, 2, 0]       )

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

         self.wait()
