from manim import *





class      lowerCAmelCase						(					_a			):



     def 			a__  (					self       ):
            _A=	Rectangle(height=0.5				,      width=0.5       )
            _A=	Rectangle(height=0.46				,      width=0.46       ).set_stroke(width=0       )

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

            _A=	[mem.copy() for i in range(1       )]
            _A=	VGroup(*_lowerCAmelCase       ).arrange(_lowerCAmelCase				,      buff=0       )
            _A=	Text('GPU'				,      font_size=24       )
            _A=	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       )

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

            _A=	Text('Model'				,      font_size=24       )
            _A=	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       )				,      )

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

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

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

            _A=	[]
            _A=	[]
            _A=	[]
            for i, rect in enumerate(_lowerCAmelCase       ):
                   _A=	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()
                   _A=	0.46 / 4
                   _A=	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()
import unittest

from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow


if is_flax_available():
      import jax

      from transformers.models.auto.modeling_flax_auto import FlaxAutoModel
      from transformers.models.bert.modeling_flax_bert import FlaxBertModel
      from transformers.models.roberta.modeling_flax_roberta import FlaxRobertaModel





@require_flax
class      lowerCAmelCase						(					unittest.TestCase			):



     @slow
     def 			a__  (					self       ):
            for model_name in ["bert-base-cased", "bert-large-uncased"]:
                   with self.subTest(lowerCAmelCase__       ):
                          _A=	AutoConfig.from_pretrained(lowerCAmelCase__       )
                          self.assertIsNotNone(lowerCAmelCase__       )
                          self.assertIsInstance(lowerCAmelCase__				,      lowerCAmelCase__       )

                          _A=	FlaxAutoModel.from_pretrained(lowerCAmelCase__       )
                          self.assertIsNotNone(lowerCAmelCase__       )
                          self.assertIsInstance(lowerCAmelCase__				,      lowerCAmelCase__       )



     @slow
     def 			a__  (					self       ):
            for model_name in ["roberta-base", "roberta-large"]:
                   with self.subTest(lowerCAmelCase__       ):
                          _A=	AutoConfig.from_pretrained(lowerCAmelCase__       )
                          self.assertIsNotNone(lowerCAmelCase__       )
                          self.assertIsInstance(lowerCAmelCase__				,      lowerCAmelCase__       )

                          _A=	FlaxAutoModel.from_pretrained(lowerCAmelCase__       )
                          self.assertIsNotNone(lowerCAmelCase__       )
                          self.assertIsInstance(lowerCAmelCase__				,      lowerCAmelCase__       )



     @slow
     def 			a__  (					self       ):
            for model_name in ["bert-base-cased", "bert-large-uncased"]:
                   _A=	AutoTokenizer.from_pretrained(lowerCAmelCase__       )
                   _A=	FlaxBertModel.from_pretrained(lowerCAmelCase__       )
                   _A=	tokenizer('Do you support jax jitted function?'				,      return_tensors=TensorType.JAX       )

                   @jax.jit
                   def eval(**lowerCAmelCase__       ):
                          return model(**lowerCAmelCase__       )

                   eval(**lowerCAmelCase__       ).block_until_ready()



     @slow
     def 			a__  (					self       ):
            for model_name in ["roberta-base", "roberta-large"]:
                   _A=	AutoTokenizer.from_pretrained(lowerCAmelCase__       )
                   _A=	FlaxRobertaModel.from_pretrained(lowerCAmelCase__       )
                   _A=	tokenizer('Do you support jax jitted function?'				,      return_tensors=TensorType.JAX       )

                   @jax.jit
                   def eval(**lowerCAmelCase__       ):
                          return model(**lowerCAmelCase__       )

                   eval(**lowerCAmelCase__       ).block_until_ready()



     def 			a__  (					self       ):
            with self.assertRaisesRegex(
                lowerCAmelCase__				,      'bert-base is not a local folder and is not a valid model identifier'       ):
                   _A=	FlaxAutoModel.from_pretrained('bert-base'       )



     def 			a__  (					self       ):
            with self.assertRaisesRegex(
                lowerCAmelCase__				,      r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'       ):
                   _A=	FlaxAutoModel.from_pretrained(lowerCAmelCase__				,      revision='aaaaaa'       )



     def 			a__  (					self       ):
            with self.assertRaisesRegex(
                lowerCAmelCase__				,      'hf-internal-testing/config-no-model does not appear to have a file named flax_model.msgpack'				,      ):
                   _A=	FlaxAutoModel.from_pretrained('hf-internal-testing/config-no-model'       )





     def 			a__  (					self       ):
            with self.assertRaisesRegex(lowerCAmelCase__				,      'Use `from_pt=True` to load this model'       ):
                   _A=	FlaxAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only'       )