





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


UpperCAmelCase_      							=     threading.Lock()
UpperCAmelCase_      							=     None

UpperCAmelCase_      							=     {
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

UpperCAmelCase_      							=     logging.WARNING

UpperCAmelCase_      							=     True





def 						lowerCamelCase__     (     )			-> Optional[Any]:



     '''simple docstring'''




     _snake_case									=				os.getenv('TRANSFORMERS_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 TRANSFORMERS_VERBOSITY={env_level_str}, '''
                   F'''has to be one of: { ", ".join(log_levels.keys()						) }'''						)
     return _default_log_level





def 						lowerCamelCase__     (     )			-> str:



     '''simple docstring'''




     return __name__.split('.'						)[0]





def 						lowerCamelCase__     (     )			-> logging.Logger:



     '''simple docstring'''




     return logging.getLogger(_get_library_name()						)





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     global _default_handler

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

          # Apply our default configuration to the library root logger.
          _snake_case									=				_get_library_root_logger()
          library_root_logger.addHandler(_default_handler						)
          library_root_logger.setLevel(_get_default_logging_level()						)
          _snake_case									=				False





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     global _default_handler

     with _lock:
          if not _default_handler:
               return

          _snake_case									=				_get_library_root_logger()
          library_root_logger.removeHandler(_default_handler						)
          library_root_logger.setLevel(logging.NOTSET						)
          _snake_case									=				None





def 						lowerCamelCase__     (     )			-> Any:



     '''simple docstring'''




     return log_levels





def 						lowerCamelCase__     (     UpperCamelCase__			:       Optional[str] = None						)			-> logging.Logger:



     '''simple docstring'''




     if name is None:
          _snake_case									=				_get_library_name()

     _configure_library_root_logger()
     return logging.getLogger(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> int:



     '''simple docstring'''




     _configure_library_root_logger()
     return _get_library_root_logger().getEffectiveLevel()





def 						lowerCamelCase__     (     UpperCamelCase__			:       int						)			-> None:



     '''simple docstring'''




     _configure_library_root_logger()
     _get_library_root_logger().setLevel(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> List[Any]:



     '''simple docstring'''




     return set_verbosity(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> List[Any]:



     '''simple docstring'''




     return set_verbosity(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> str:



     '''simple docstring'''




     return set_verbosity(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> List[Any]:



     '''simple docstring'''




     return set_verbosity(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     _configure_library_root_logger()

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





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     _configure_library_root_logger()

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





def 						lowerCamelCase__     (     UpperCamelCase__			:       logging.Handler						)			-> None:



     '''simple docstring'''




     _configure_library_root_logger()

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





def 						lowerCamelCase__     (     UpperCamelCase__			:       logging.Handler						)			-> None:



     '''simple docstring'''




     _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 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     _configure_library_root_logger()
     _snake_case									=				False





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     _configure_library_root_logger()
     _snake_case									=				True





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     _snake_case									=				_get_library_root_logger().handlers

     for handler in handlers:
          _snake_case									=				logging.Formatter('[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s'						)
          handler.setFormatter(UpperCamelCase__						)





def 						lowerCamelCase__     (     )			-> None:



     '''simple docstring'''




     _snake_case									=				_get_library_root_logger().handlers

     for handler in handlers:
          handler.setFormatter(UpperCamelCase__						)





def 						lowerCamelCase__     (     self			:       Union[str, Any]       ,    *UpperCamelCase__			:       List[str]       ,    **UpperCamelCase__			:       str						)			-> Optional[Any]:



     '''simple docstring'''




     _snake_case									=				os.getenv('TRANSFORMERS_NO_ADVISORY_WARNINGS'       ,    UpperCamelCase__						)
     if no_advisory_warnings:
          return
     self.warning(*UpperCamelCase__       ,    **UpperCamelCase__						)


UpperCAmelCase_      							=     warning_advice





@functools.lru_cache(UpperCamelCase__						)
def 						lowerCamelCase__     (     self			:       Optional[Any]       ,    *UpperCamelCase__			:       Union[str, Any]       ,    **UpperCamelCase__			:       Dict						)			-> int:



     '''simple docstring'''




     self.warning(*UpperCamelCase__       ,    **UpperCamelCase__						)


UpperCAmelCase_      							=     warning_once
class 			UpperCamelCase_		:




     def __init__(		self				,						*lowerCAmelCase_				,						**lowerCAmelCase_  )		->							int:  # pylint: disable=unused-argument
          _snake_case									=				args[0] if args else None




     def __iter__(		self  )		->							str:
          return iter(self._iterator  )




     def __getattr__(		self				,						lowerCAmelCase_  )		->							int:

          def empty_fn(*lowerCAmelCase_				,						**lowerCAmelCase_  ):  # pylint: disable=unused-argument
               return

          return empty_fn




     def __enter__(		self  )		->							Optional[int]:
          return self






     def __exit__(		self				,						lowerCAmelCase_				,						lowerCAmelCase_				,						lowerCAmelCase_  )		->							Tuple:
          return





class 			UpperCamelCase_		:




     def __call__(		self				,						*lowerCAmelCase_				,						**lowerCAmelCase_  )		->							List[str]:
          if _tqdm_active:
               return tqdm_lib.tqdm(*lowerCAmelCase_				,						**lowerCAmelCase_  )
          else:
               return EmptyTqdm(*lowerCAmelCase_				,						**lowerCAmelCase_  )




     def 	lowerCAmelCase			(		self				,						*lowerCAmelCase_				,						**lowerCAmelCase_  )		->							List[str]:
          _snake_case									=				None
          if _tqdm_active:
               return tqdm_lib.tqdm.set_lock(*lowerCAmelCase_				,						**lowerCAmelCase_  )






     def 	lowerCAmelCase			(		self  )		->							Optional[int]:
          if _tqdm_active:
               return tqdm_lib.tqdm.get_lock()





UpperCAmelCase_      							=     _tqdm_cls()





def 						lowerCamelCase__     (     )			-> bool:



     '''simple docstring'''




     global _tqdm_active
     return bool(_tqdm_active						)





def 						lowerCamelCase__     (     )			-> Union[str, Any]:



     '''simple docstring'''




     global _tqdm_active
     _snake_case									=				True
     hf_hub_utils.enable_progress_bars()





def 						lowerCamelCase__     (     )			-> Tuple:



     '''simple docstring'''




     global _tqdm_active
     _snake_case									=				False
     hf_hub_utils.disable_progress_bars()










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCAmelCase_      							=     {
    """configuration_bigbird_pegasus""": [
        """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """BigBirdPegasusConfig""",
        """BigBirdPegasusOnnxConfig""",
    ],
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase_      							=     [
					    """BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """BigBirdPegasusForCausalLM""",
					    """BigBirdPegasusForConditionalGeneration""",
					    """BigBirdPegasusForQuestionAnswering""",
					    """BigBirdPegasusForSequenceClassification""",
					    """BigBirdPegasusModel""",
					    """BigBirdPegasusPreTrainedModel""",
					]


if TYPE_CHECKING:
					from .configuration_bigbird_pegasus import (
					    BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    BigBirdPegasusConfig,
					    BigBirdPegasusOnnxConfig,
					)

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_bigbird_pegasus import (
										    BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
										    BigBirdPegasusForCausalLM,
										    BigBirdPegasusForConditionalGeneration,
										    BigBirdPegasusForQuestionAnswering,
										    BigBirdPegasusForSequenceClassification,
										    BigBirdPegasusModel,
										    BigBirdPegasusPreTrainedModel,
										)


else:
					import sys

					UpperCAmelCase_      							=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



