


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

from tqdm import auto as tqdm_lib


A__:   Tuple    =	threading.Lock()
A__:   Optional[logging.Handler]    =	None

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

A__:   List[str]    =	logging.WARNING

A__:   Tuple    =	True


def      SCREAMING_SNAKE_CASE_ (  )  ->      int:
       _a   :			Optional[int]					 =os.getenv("""DIFFUSERS_VERBOSITY"""   ,_UpperCAmelCase  )
       if env_level_str:
              if env_level_str in log_levels:
                     return log_levels[env_level_str]
              else:
                     logging.getLogger().warning(
                         F"Unknown option DIFFUSERS_VERBOSITY={env_level_str}, "
                         F"has to be one of: { ', '.join(log_levels.keys()  ) }"  )
       return _default_log_level


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


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


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       global _default_handler

       with _lock:
              if _default_handler:
                     # This library has already configured the library root logger.
                     return
              _a   :			int					 =logging.StreamHandler()  # Set sys.stderr as stream.
              _a   :			Optional[int]					 =sys.stderr.flush

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


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       global _default_handler

       with _lock:
              if not _default_handler:
                     return

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


def      SCREAMING_SNAKE_CASE_ (  )  ->      Any:
       return log_levels


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     Optional[str] = None  )  ->      logging.Logger:

       if name is None:
              _a   :			int					 =_get_library_name()

       _configure_library_root_logger()
       return logging.getLogger(_UpperCAmelCase  )


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


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     int  )  ->      None:
       _configure_library_root_logger()
       _get_library_root_logger().setLevel(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  )  ->      Optional[int]:
       return set_verbosity(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  )  ->      Union[str, Any]:
       return set_verbosity(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  )  ->      List[Any]:
       return set_verbosity(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  )  ->      Optional[Any]:
       return set_verbosity(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       _configure_library_root_logger()

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


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       _configure_library_root_logger()

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


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     logging.Handler  )  ->      None:
       _configure_library_root_logger()

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


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     logging.Handler  )  ->      None:
       _configure_library_root_logger()

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


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       _configure_library_root_logger()
       _a   :			Union[str, Any]					 =False


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       _configure_library_root_logger()
       _a   :			Union[str, Any]					 =True


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       _a   :			str					 =_get_library_root_logger().handlers

       for handler in handlers:
              _a   :			Dict					 =logging.Formatter("""[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"""  )
              handler.setFormatter(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  )  ->      None:
       _a   :			List[Any]					 =_get_library_root_logger().handlers

       for handler in handlers:
              handler.setFormatter(_UpperCAmelCase  )


def      SCREAMING_SNAKE_CASE_ (  self     :     Union[str, Any]   ,*_UpperCAmelCase     :     Optional[Any]   ,**_UpperCAmelCase     :     Tuple  )  ->      List[Any]:
       _a   :			Optional[Any]					 =os.getenv("""DIFFUSERS_NO_ADVISORY_WARNINGS"""   ,_UpperCAmelCase  )
       if no_advisory_warnings:
              return
       self.warning(*_UpperCAmelCase   ,**_UpperCAmelCase  )


A__:   Union[str, Any]    =	warning_advice







class A__	:






      def __init__(			self      :Any					,						*SCREAMING_SNAKE_CASE      :int					,						**SCREAMING_SNAKE_CASE      :int     )	-> Any:  # pylint: disable=unused-argument




             '''simple docstring'''
             _a   :			Optional[int]					 =args[0] if args else None






      def __iter__(			self      :str     )	-> Tuple:




             '''simple docstring'''
             return iter(self._iterator     )






      def __getattr__(			self      :Union[str, Any]					,						SCREAMING_SNAKE_CASE      :Optional[int]     )	-> Any:




             '''simple docstring'''

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

             return empty_fn






      def __enter__(			self      :Optional[Any]     )	-> str:




             '''simple docstring'''
             return self






      def __exit__(			self      :List[Any]					,						SCREAMING_SNAKE_CASE      :Dict					,						SCREAMING_SNAKE_CASE      :str					,						SCREAMING_SNAKE_CASE      :Any     )	-> Optional[int]:




             '''simple docstring'''
             return







class A__	:






      def __call__(			self      :Any					,						*SCREAMING_SNAKE_CASE      :int					,						**SCREAMING_SNAKE_CASE      :int     )	-> Optional[int]:




             '''simple docstring'''
             if _tqdm_active:
                    return tqdm_lib.tqdm(*SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )
             else:
                    return EmptyTqdm(*SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )






      def __UpperCAmelCase	(			self      :Optional[Any]					,						*SCREAMING_SNAKE_CASE      :Optional[int]					,						**SCREAMING_SNAKE_CASE      :Union[str, Any]     )	-> Any:




             '''simple docstring'''
             _a   :			Dict					 =None
             if _tqdm_active:
                    return tqdm_lib.tqdm.set_lock(*SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )






      def __UpperCAmelCase	(			self      :int     )	-> Tuple:




             '''simple docstring'''
             if _tqdm_active:
                    return tqdm_lib.tqdm.get_lock()

A__:   str    =	_tqdm_cls()


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


def      SCREAMING_SNAKE_CASE_ (  )  ->      Optional[Any]:
       global _tqdm_active
       _a   :			Optional[int]					 =True


def      SCREAMING_SNAKE_CASE_ (  )  ->      Tuple:
       global _tqdm_active
       _a   :			int					 =False






'''simple docstring'''







import copy
from typing import Dict

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING
from ..bit import BitConfig


A__:   List[Any]    =	logging.get_logger(__name__)

A__:   List[Any]    =	{
    '''google/vit-hybrid-base-bit-384''': '''https://huggingface.co/vit-hybrid-base-bit-384/resolve/main/config.json''',
    # See all ViT hybrid models at https://huggingface.co/models?filter=vit
}







class A__	(						UpperCAmelCase__				):
      __UpperCamelCase	:  Dict     	=							"vit-hybrid"






      def __init__(			self      :List[Any]					,						SCREAMING_SNAKE_CASE      :Dict=None					,						SCREAMING_SNAKE_CASE      :Any=7_6_8					,						SCREAMING_SNAKE_CASE      :Optional[Any]=1_2					,						SCREAMING_SNAKE_CASE      :int=1_2					,						SCREAMING_SNAKE_CASE      :Any=3_0_7_2					,						SCREAMING_SNAKE_CASE      :List[str]="gelu"					,						SCREAMING_SNAKE_CASE      :str=0.0					,						SCREAMING_SNAKE_CASE      :Dict=0.0					,						SCREAMING_SNAKE_CASE      :Dict=0.02					,						SCREAMING_SNAKE_CASE      :Tuple=1e-12					,						SCREAMING_SNAKE_CASE      :List[Any]=2_2_4					,						SCREAMING_SNAKE_CASE      :Union[str, Any]=1					,						SCREAMING_SNAKE_CASE      :List[Any]=3					,						SCREAMING_SNAKE_CASE      :Optional[Any]=[1, 1_0_2_4, 2_4, 2_4]					,						SCREAMING_SNAKE_CASE      :Optional[Any]=True					,						**SCREAMING_SNAKE_CASE      :Dict					,						)	-> List[Any]:




             '''simple docstring'''
             super().__init__(**SCREAMING_SNAKE_CASE     )

             if backbone_config is None:
                    logger.info("""`backbone_config` is `None`. Initializing the config with a `BiT` backbone."""     )
                    _a   :			Optional[int]					 ={
                        """global_padding""": """same""",
                        """layer_type""": """bottleneck""",
                        """depths""": [3, 4, 9],
                        """out_features""": ["""stage3"""],
                        """embedding_dynamic_padding""": True,
                    }

             if isinstance(SCREAMING_SNAKE_CASE					,						SCREAMING_SNAKE_CASE     ):
                    if "model_type" in backbone_config:
                           _a   :			Dict					 =CONFIG_MAPPING[backbone_config["""model_type"""]]
                    else:
                           logger.info(
                               """`model_type` is not found in `backbone_config`. Use `Bit` as the backbone configuration class."""     )
                           _a   :			List[str]					 =BitConfig
                    _a   :			List[Any]					 =backbone_config_class(**SCREAMING_SNAKE_CASE     )

             _a   :			str					 =backbone_featmap_shape
             _a   :			Dict					 =backbone_config
             _a   :			Tuple					 =hidden_size
             _a   :			Union[str, Any]					 =num_hidden_layers
             _a   :			Tuple					 =num_attention_heads
             _a   :			int					 =intermediate_size
             _a   :			Any					 =hidden_act
             _a   :			Union[str, Any]					 =hidden_dropout_prob
             _a   :			Any					 =attention_probs_dropout_prob
             _a   :			Tuple					 =initializer_range
             _a   :			int					 =layer_norm_eps
             _a   :			Union[str, Any]					 =image_size
             _a   :			str					 =patch_size
             _a   :			Optional[int]					 =num_channels
             _a   :			Union[str, Any]					 =qkv_bias






      def __UpperCAmelCase	(			self      :Optional[Any]     )	-> Dict[str, any]:




             '''simple docstring'''
             _a   :			Dict					 =copy.deepcopy(self.__dict__     )
             _a   :			Tuple					 =self.backbone_config.to_dict()
             _a   :			str					 =self.__class__.model_type
             return output


