
import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


lowerCamelCase_						: Optional[Any]         =  threading.Lock()
lowerCamelCase_						: Optional[logging.Handler]         =  None

lowerCamelCase_						: Union[str, Any]         =  {
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

lowerCamelCase_						: List[str]         =  logging.WARNING

lowerCamelCase_						: Optional[int]         =  True







def        A__					(						)  ->	Any:
    UpperCamelCase_:							Dict	=						os.getenv("""TRANSFORMERS_VERBOSITY"""     ,    lowerCamelCase						)
    if env_level_str:
        if env_level_str in log_levels:
            return log_levels[env_level_str]
        else:
            logging.getLogger().warning(
                F'''Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, '''
                F'''has to be one of: { ", ".join(log_levels.keys()						) }'''						)
    return _default_log_level







def        A__					(						)  ->	str:
    return __name__.split("""."""						)[0]







def        A__					(						)  ->	logging.Logger:
    return logging.getLogger(_get_library_name()						)







def        A__					(						)  ->	None:
    global _default_handler

    with _lock:
        if _default_handler:
            # This library has already configured the library root logger.
            return
        UpperCamelCase_:							Any	=						logging.StreamHandler()  # Set sys.stderr as stream.
        UpperCamelCase_:							Union[str, Any]	=						sys.stderr.flush

        # Apply our default configuration to the library root logger.
        UpperCamelCase_:							Union[str, Any]	=						_get_library_root_logger()
        library_root_logger.addHandler(_default_handler						)
        library_root_logger.setLevel(_get_default_logging_level()						)
        UpperCamelCase_:							Any	=						False







def        A__					(						)  ->	None:
    global _default_handler

    with _lock:
        if not _default_handler:
            return

        UpperCamelCase_:							List[Any]	=						_get_library_root_logger()
        library_root_logger.removeHandler(_default_handler						)
        library_root_logger.setLevel(logging.NOTSET						)
        UpperCamelCase_:							int	=						None







def        A__					(						)  ->	Optional[Any]:
    return log_levels







def        A__					(						lowerCamelCase = None						)  ->	logging.Logger:

    if name is None:
        UpperCamelCase_:							str	=						_get_library_name()

    _configure_library_root_logger()
    return logging.getLogger(lowerCamelCase						)







def        A__					(						)  ->	int:
    _configure_library_root_logger()
    return _get_library_root_logger().getEffectiveLevel()







def        A__					(						lowerCamelCase						)  ->	None:
    _configure_library_root_logger()
    _get_library_root_logger().setLevel(lowerCamelCase						)







def        A__					(						)  ->	Any:
    return set_verbosity(lowerCamelCase						)







def        A__					(						)  ->	Optional[int]:
    return set_verbosity(lowerCamelCase						)







def        A__					(						)  ->	Any:
    return set_verbosity(lowerCamelCase						)







def        A__					(						)  ->	Dict:
    return set_verbosity(lowerCamelCase						)







def        A__					(						)  ->	None:
    _configure_library_root_logger()

    assert _default_handler is not None
    _get_library_root_logger().removeHandler(_default_handler						)







def        A__					(						)  ->	None:
    _configure_library_root_logger()

    assert _default_handler is not None
    _get_library_root_logger().addHandler(_default_handler						)







def        A__					(						lowerCamelCase						)  ->	None:
    _configure_library_root_logger()

    assert handler is not None
    _get_library_root_logger().addHandler(lowerCamelCase						)







def        A__					(						lowerCamelCase						)  ->	None:
    _configure_library_root_logger()

    assert handler is not None and handler not in _get_library_root_logger().handlers
    _get_library_root_logger().removeHandler(lowerCamelCase						)







def        A__					(						)  ->	None:
    _configure_library_root_logger()
    UpperCamelCase_:							Any	=						False







def        A__					(						)  ->	None:
    _configure_library_root_logger()
    UpperCamelCase_:							List[str]	=						True







def        A__					(						)  ->	None:
    UpperCamelCase_:							List[str]	=						_get_library_root_logger().handlers

    for handler in handlers:
        UpperCamelCase_:							Optional[int]	=						logging.Formatter("""[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"""						)
        handler.setFormatter(lowerCamelCase						)







def        A__					(						)  ->	None:
    UpperCamelCase_:							int	=						_get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(lowerCamelCase						)







def        A__					(						self     ,    *lowerCamelCase     ,    **lowerCamelCase						)  ->	List[str]:
    UpperCamelCase_:							List[str]	=						os.getenv("""TRANSFORMERS_NO_ADVISORY_WARNINGS"""     ,    lowerCamelCase						)
    if no_advisory_warnings:
        return
    self.warning(*lowerCamelCase     ,    **lowerCamelCase						)


lowerCamelCase_						: Tuple         =  warning_advice







@functools.lru_cache(lowerCamelCase						)
def        A__					(						self     ,    *lowerCamelCase     ,    **lowerCamelCase						)  ->	Union[str, Any]:
    self.warning(*lowerCamelCase     ,    **lowerCamelCase						)


lowerCamelCase_						: List[str]         =  warning_once

class        _UpperCamelCase				:






   '''simple docstring'''

   def __init__(       self :       Tuple						,	*snake_case_ :       Optional[Any]						,	**snake_case_ :       Union[str, Any]      ):  # pylint: disable=unused-argument
       UpperCamelCase_:							Tuple	=						args[0] if args else None

   def __iter__(       self :       Tuple      ):
       return iter(self._iterator      )

   def __getattr__(       self :       Tuple						,	snake_case_ :       Optional[Any]      ):

       def empty_fn(*snake_case_ :       str						,	**snake_case_ :       Optional[int]      ):  # pylint: disable=unused-argument
           return

       return empty_fn

   def __enter__(       self :       List[str]      ):
       return self




   def __exit__(       self :       Optional[int]						,	snake_case_ :       List[str]						,	snake_case_ :       Tuple						,	snake_case_ :       Optional[Any]      ):
       return




class        _UpperCamelCase				:






   '''simple docstring'''

   def __call__(       self :       Any						,	*snake_case_ :       str						,	**snake_case_ :       Dict      ):
       if _tqdm_active:
           return tqdm_lib.tqdm(*snake_case_						,	**snake_case_      )
       else:
           return EmptyTqdm(*snake_case_						,	**snake_case_      )

   def       lowerCAmelCase__	(       self :       Tuple						,	*snake_case_ :       Tuple						,	**snake_case_ :       Dict      ):
       UpperCamelCase_:							Tuple	=						None
       if _tqdm_active:
           return tqdm_lib.tqdm.set_lock(*snake_case_						,	**snake_case_      )




   def       lowerCAmelCase__	(       self :       int      ):
       if _tqdm_active:
           return tqdm_lib.tqdm.get_lock()




lowerCamelCase_						: List[str]         =  _tqdm_cls()







def        A__					(						)  ->	bool:
    global _tqdm_active
    return bool(_tqdm_active						)







def        A__					(						)  ->	List[Any]:
    global _tqdm_active
    UpperCamelCase_:							Dict	=						True
    hf_hub_utils.enable_progress_bars()







def        A__					(						)  ->	List[Any]:
    global _tqdm_active
    UpperCamelCase_:							Tuple	=						False
    hf_hub_utils.disable_progress_bars()








from manim import *

class        _UpperCamelCase				(					_A  ):






			'''simple docstring'''

			def       lowerCAmelCase__	(       self :       int      ):
							UpperCamelCase_:							Dict	=						Rectangle(height=0.5						,	width=0.5      )
							UpperCamelCase_:							Dict	=						Rectangle(height=0.46						,	width=0.46      ).set_stroke(width=0      )

							UpperCamelCase_:							Tuple	=						[mem.copy() for i in range(6      )]
							UpperCamelCase_:							List[str]	=						[mem.copy() for i in range(6      )]
							UpperCamelCase_:							List[str]	=						VGroup(*snake_case_      ).arrange(snake_case_						,	buff=0      )
							UpperCamelCase_:							Tuple	=						VGroup(*snake_case_      ).arrange(snake_case_						,	buff=0      )
							UpperCamelCase_:							Union[str, Any]	=						VGroup(snake_case_						,	snake_case_      ).arrange(snake_case_						,	buff=0      )
							UpperCamelCase_:							Optional[Any]	=						Text("""CPU"""						,	font_size=24      )
							UpperCamelCase_:							int	=						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_:							Optional[int]	=						[mem.copy() for i in range(1      )]
							UpperCamelCase_:							Dict	=						VGroup(*snake_case_      ).arrange(snake_case_						,	buff=0      )
							UpperCamelCase_:							Optional[int]	=						Text("""GPU"""						,	font_size=24      )
							UpperCamelCase_:							Optional[int]	=						Group(snake_case_						,	snake_case_      ).arrange(snake_case_						,	buff=0.5						,	aligned_edge=snake_case_      )
							gpu.align_to(snake_case_						,	snake_case_      )
							gpu.set_x(gpu.get_x() - 1      )

							self.add(snake_case_      )

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

							UpperCamelCase_:							Any	=						Text("""Model"""						,	font_size=24      )
							UpperCamelCase_:							Optional[Any]	=						Group(snake_case_						,	snake_case_      ).arrange(snake_case_						,	buff=0.5						,	aligned_edge=snake_case_      )
							model.move_to([3, -1.0, 0]      )

							self.play(
							    Create(snake_case_						,	run_time=1      )						,	Create(snake_case_						,	run_time=1      )						,	Create(snake_case_						,	run_time=1      )						,	)

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

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

							UpperCamelCase_:							Union[str, Any]	=						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(snake_case_						,	run_time=2.5      )						,	Write(snake_case_      )						,	Write(snake_case_      )      )

							self.add(snake_case_      )

							UpperCamelCase_:							Union[str, Any]	=						[]
							UpperCamelCase_:							Union[str, Any]	=						[]
							UpperCamelCase_:							Tuple	=						[]
							for i, rect in enumerate(snake_case_      ):
											UpperCamelCase_:							Tuple	=						Rectangle(height=0.46						,	width=0.46      ).set_stroke(width=0.0      ).set_fill(snake_case_						,	opacity=0.7      )
											cpu_target.move_to(snake_case_      )
											cpu_target.generate_target()
											UpperCamelCase_:							int	=						0.46 / 4
											UpperCamelCase_:							Optional[int]	=						0.46 / 3

											if i == 0:
															cpu_target.target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT      )						,	buff=0.02						,	direction=snake_case_      )
															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=snake_case_						,	buff=0.0      )
											else:
															cpu_target.target.next_to(cpu_targs[i - 1].target						,	direction=snake_case_						,	buff=0.0      )
											cpu_targs.append(snake_case_      )

											first_animations.append(rect.animate(run_time=0.5      ).set_stroke(snake_case_      )      )
											second_animations.append(MoveToTarget(snake_case_						,	run_time=1.5      )      )

							self.play(*snake_case_      )
							self.play(*snake_case_      )

							self.wait()






