





from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


snake_case_				=			logging.get_logger(__name__)

snake_case_				=			{
    'shi-labs/nat-mini-in1k-224': 'https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json',
    # See all Nat models at https://huggingface.co/models?filter=nat
}

class 		SCREAMING_SNAKE_CASE__				(       _UpperCAmelCase						,      _UpperCAmelCase  ):
      A_						:				Any							=    'nat'

      A_						:				List[str]							=    {
          'num_attention_heads': 'num_heads',
          'num_hidden_layers': 'num_layers',
      }


      def __init__(self       :      Optional[int]				,			a__       :      Union[str, Any]=4				,			a__       :      Optional[int]=3				,			a__       :      Union[str, Any]=64				,			a__       :      Optional[Any]=[3, 4, 6, 5]				,			a__       :      Optional[int]=[2, 4, 8, 16]				,			a__       :      List[str]=7				,			a__       :      str=3.0				,			a__       :      Dict=True				,			a__       :      Any=0.0				,			a__       :      int=0.0				,			a__       :      List[str]=0.1				,			a__       :      Any="gelu"				,			a__       :      List[str]=0.0_2				,			a__       :      Optional[int]=1E-5				,			a__       :      str=0.0				,			a__       :      List[Any]=None				,			a__       :      List[Any]=None				,			**a__       :      List[str]				,			):





         """simple docstring"""



         super().__init__(**a__      )

         __snake_case							       =   patch_size
         __snake_case							       =   num_channels
         __snake_case							       =   embed_dim
         __snake_case							       =   depths
         __snake_case							       =   len(a__      )
         __snake_case							       =   num_heads
         __snake_case							       =   kernel_size
         __snake_case							       =   mlp_ratio
         __snake_case							       =   qkv_bias
         __snake_case							       =   hidden_dropout_prob
         __snake_case							       =   attention_probs_dropout_prob
         __snake_case							       =   drop_path_rate
         __snake_case							       =   hidden_act
         __snake_case							       =   layer_norm_eps
         __snake_case							       =   initializer_range
         # we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
         # this indicates the channel dimension after the last stage of the model
         __snake_case							       =   int(embed_dim * 2 ** (len(a__      ) - 1)      )
         __snake_case							       =   layer_scale_init_value
         __snake_case							       =   ['''stem'''] + [f"""stage{idx}""" for idx in range(1				,			len(a__      ) + 1      )]
         __snake_case       ,	__snake_case							       =   get_aligned_output_features_output_indices(
             out_features=a__				,			out_indices=a__				,			stage_names=self.stage_names      )








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 		SCREAMING_SNAKE_CASE__				(       unittest.TestCase  ):


      def    a (self       :      Dict      ):





         """simple docstring"""



         __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(a__      )


      def    a (self       :      Dict      ):





         """simple docstring"""



         __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(a__      ) as cl:
               logger.warning(a__      )
            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(a__      ) as cl:
            logger.warning(a__      )
         self.assertEqual(cl.out				,			''''''      )

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

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


      @mockenv(TRANSFORMERS_VERBOSITY='''error'''      )
      def    a (self       :      Dict      ):





         """simple docstring"""



         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'''				,			a__      )
         __snake_case							       =   logging.log_levels[env_level_str]

         __snake_case							       =   logging.get_verbosity()
         self.assertEqual(
             a__				,			a__				,			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    a (self       :      List[Any]      ):





         """simple docstring"""



         transformers.utils.logging._reset_library_root_logger()
         __snake_case							       =   logging.logging.getLogger()
         with CaptureLogger(a__      ) 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    a (self       :      Any      ):





         """simple docstring"""



         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(a__      ) as cl:
               logger.warning_advice(a__      )
            self.assertEqual(cl.out				,			''''''      )

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






def lowerCamelCase__    (							)      ->				str:
   disable_progress_bar()
   assert are_progress_bars_disabled()

   enable_progress_bar()
   assert not are_progress_bars_disabled()

