




'''simple docstring'''





import os
import unittest

from huggingface_hub.utils import are_progress_bars_disabled

import transformers.models.bart.tokenization_bart
from transformers import logging
from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context
from transformers.utils.logging import disable_progress_bar, enable_progress_bar

class   _a							(		unittest.TestCase				):






     def 							_lowercase      (					self       )				->     Dict:
          _snake_case				= logging.get_logger()

          # the current default level is logging.WARNING
          _snake_case				= logging.get_verbosity()

          logging.set_verbosity_error()
          self.assertEqual(logger.getEffectiveLevel()   ,logging.get_verbosity()       )

          logging.set_verbosity_warning()
          self.assertEqual(logger.getEffectiveLevel()   ,logging.get_verbosity()       )

          logging.set_verbosity_info()
          self.assertEqual(logger.getEffectiveLevel()   ,logging.get_verbosity()       )

          logging.set_verbosity_debug()
          self.assertEqual(logger.getEffectiveLevel()   ,logging.get_verbosity()       )

          # restore to the original level
          logging.set_verbosity(_SCREAMING_SNAKE_CASE       )






     def 							_lowercase      (					self       )				->     Optional[int]:
          _snake_case				= logging.get_verbosity()

          _snake_case				= logging.get_logger("transformers.models.bart.tokenization_bart"       )
          _snake_case				= "Testing 1, 2, 3"

          # should be able to log warnings (if default settings weren't overridden by `pytest --log-level-all`)
          if level_origin <= logging.WARNING:
               with CaptureLogger(_SCREAMING_SNAKE_CASE       ) as cl:
                    logger.warning(_SCREAMING_SNAKE_CASE       )
               self.assertEqual(cl.out   ,msg + "\n"       )

          # this is setting the level for all of `transformers.*` loggers
          logging.set_verbosity_error()

          # should not be able to log warnings
          with CaptureLogger(_SCREAMING_SNAKE_CASE       ) as cl:
               logger.warning(_SCREAMING_SNAKE_CASE       )
          self.assertEqual(cl.out   ,""       )

          # should be able to log warnings again
          logging.set_verbosity_warning()
          with CaptureLogger(_SCREAMING_SNAKE_CASE       ) as cl:
               logger.warning(_SCREAMING_SNAKE_CASE       )
          self.assertEqual(cl.out   ,msg + "\n"       )

          # restore to the original level
          logging.set_verbosity(_SCREAMING_SNAKE_CASE       )






     @mockenv(TRANSFORMERS_VERBOSITY="error"       )
     def 							_lowercase      (					self       )				->     List[str]:
          # reset for the env var to take effect, next time some logger call is made
          transformers.utils.logging._reset_library_root_logger()
          # this action activates the env var
          _snake_case				= logging.get_logger("transformers.models.bart.tokenization_bart"       )

          _snake_case				= os.getenv("TRANSFORMERS_VERBOSITY"   ,_SCREAMING_SNAKE_CASE       )
          _snake_case				= logging.log_levels[env_level_str]

          _snake_case				= logging.get_verbosity()
          self.assertEqual(
              _SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE   ,f"""TRANSFORMERS_VERBOSITY={env_level_str}/{env_level}, but internal verbosity is {current_level}"""   ,)

          # restore to the original level
          _snake_case				= ""
          transformers.utils.logging._reset_library_root_logger()






     @mockenv(TRANSFORMERS_VERBOSITY="super-error"       )
     def 							_lowercase      (					self       )				->     List[Any]:
          # reset for the env var to take effect, next time some logger call is made
          transformers.utils.logging._reset_library_root_logger()
          _snake_case				= logging.logging.getLogger()
          with CaptureLogger(_SCREAMING_SNAKE_CASE       ) as cl:
               # this action activates the env var
               logging.get_logger("transformers.models.bart.tokenization_bart"       )
          self.assertIn("Unknown option TRANSFORMERS_VERBOSITY=super-error"   ,cl.out       )

          # no need to restore as nothing was changed






     def 							_lowercase      (					self       )				->     Optional[int]:
          # testing `logger.warning_advice()`
          transformers.utils.logging._reset_library_root_logger()

          _snake_case				= logging.get_logger("transformers.models.bart.tokenization_bart"       )
          _snake_case				= "Testing 1, 2, 3"

          with mockenv_context(TRANSFORMERS_NO_ADVISORY_WARNINGS="1"       ):
               # nothing should be logged as env var disables this method
               with CaptureLogger(_SCREAMING_SNAKE_CASE       ) as cl:
                    logger.warning_advice(_SCREAMING_SNAKE_CASE       )
               self.assertEqual(cl.out   ,""       )

          with mockenv_context(TRANSFORMERS_NO_ADVISORY_WARNINGS=""       ):
               # should log normally as TRANSFORMERS_NO_ADVISORY_WARNINGS is unset
               with CaptureLogger(_SCREAMING_SNAKE_CASE       ) as cl:
                    logger.warning_advice(_SCREAMING_SNAKE_CASE       )
               self.assertEqual(cl.out   ,msg + "\n"       )







def       __a      (  )		->					Dict:

     """simple docstring"""




     disable_progress_bar()
     assert are_progress_bars_disabled()

     enable_progress_bar()
     assert not are_progress_bars_disabled()








'''simple docstring'''





from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase_		:     int          =		logging.get_logger(__name__)

UpperCamelCase_		:     Any          =		{
    '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''',
    '''tiiuae/falcon-7b''': '''https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json''',
}

class   _a							(		__lowerCAmelCase				):
     SCREAMING_SNAKE_CASE_				:       List[str]       							=		"""falcon"""
     SCREAMING_SNAKE_CASE_				:       Optional[int]       							=		["""past_key_values"""]






     def __init__(					self   ,_SCREAMING_SNAKE_CASE=65_024   ,_SCREAMING_SNAKE_CASE=4_544   ,_SCREAMING_SNAKE_CASE=32   ,_SCREAMING_SNAKE_CASE=71   ,_SCREAMING_SNAKE_CASE=1e-5   ,_SCREAMING_SNAKE_CASE=0.0_2   ,_SCREAMING_SNAKE_CASE=True   ,_SCREAMING_SNAKE_CASE=0.0   ,_SCREAMING_SNAKE_CASE=0.0   ,_SCREAMING_SNAKE_CASE=None   ,_SCREAMING_SNAKE_CASE=False   ,_SCREAMING_SNAKE_CASE=False   ,_SCREAMING_SNAKE_CASE=True   ,_SCREAMING_SNAKE_CASE=True   ,_SCREAMING_SNAKE_CASE=False   ,_SCREAMING_SNAKE_CASE=11   ,_SCREAMING_SNAKE_CASE=11   ,**_SCREAMING_SNAKE_CASE   ,)				->     Dict:
          _snake_case				= vocab_size
          # Backward compatibility with n_embed kwarg
          _snake_case				= kwargs.pop("n_embed"   ,_SCREAMING_SNAKE_CASE       )
          _snake_case				= hidden_size if n_embed is None else n_embed
          _snake_case				= num_hidden_layers
          _snake_case				= num_attention_heads
          _snake_case				= layer_norm_epsilon
          _snake_case				= initializer_range
          _snake_case				= use_cache
          _snake_case				= hidden_dropout
          _snake_case				= attention_dropout

          _snake_case				= bos_token_id
          _snake_case				= eos_token_id
          _snake_case				= num_attention_heads if num_kv_heads is None else num_kv_heads
          _snake_case				= alibi
          _snake_case				= new_decoder_architecture
          _snake_case				= multi_query  # Ignored when new_decoder_architecture is True
          _snake_case				= parallel_attn
          _snake_case				= bias

          super().__init__(bos_token_id=_SCREAMING_SNAKE_CASE   ,eos_token_id=_SCREAMING_SNAKE_CASE   ,**_SCREAMING_SNAKE_CASE       )






     @property
     def 							_lowercase      (					self       )				->     Union[str, Any]:
          return self.hidden_size // self.num_attention_heads






     @property
     def 							_lowercase      (					self       )				->     Optional[int]:
          return not self.alibi


