






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







		'''simple docstring'''



		def 					__UpperCAmelCase			(							self   )	->							Tuple:
							UpperCAmelCase_    :      List[str]            =						logging.get_logger()

							# the current default level is logging.WARNING
							UpperCAmelCase_    :      str            =						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(_UpperCamelCase   )



		def 					__UpperCAmelCase			(							self   )	->							Dict:
							UpperCAmelCase_    :      Dict            =						logging.get_verbosity()

							UpperCAmelCase_    :      List[str]            =						logging.get_logger('transformers.models.bart.tokenization_bart'   )
							UpperCAmelCase_    :      Dict            =						'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(_UpperCamelCase   ) as cl:
																	logger.warning(_UpperCamelCase   )
												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(_UpperCamelCase   ) as cl:
												logger.warning(_UpperCamelCase   )
							self.assertEqual(cl.out				,		''   )

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

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



		@mockenv(TRANSFORMERS_VERBOSITY='error'   )
		def 					__UpperCAmelCase			(							self   )	->							Union[str, Any]:
							# 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
							UpperCAmelCase_    :      List[str]            =						logging.get_logger('transformers.models.bart.tokenization_bart'   )

							UpperCAmelCase_    :      Tuple            =						os.getenv('TRANSFORMERS_VERBOSITY'				,		_UpperCamelCase   )
							UpperCAmelCase_    :      List[str]            =						logging.log_levels[env_level_str]

							UpperCAmelCase_    :      Dict            =						logging.get_verbosity()
							self.assertEqual(
							    _UpperCamelCase				,		_UpperCamelCase				,		f"TRANSFORMERS_VERBOSITY={env_level_str}/{env_level}, but internal verbosity is {current_level}"				,		)

							# restore to the original level
							UpperCAmelCase_    :      Tuple            =						''
							transformers.utils.logging._reset_library_root_logger()



		@mockenv(TRANSFORMERS_VERBOSITY='super-error'   )
		def 					__UpperCAmelCase			(							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()
							UpperCAmelCase_    :      Any            =						logging.logging.getLogger()
							with CaptureLogger(_UpperCamelCase   ) 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 					__UpperCAmelCase			(							self   )	->							Union[str, Any]:
							# testing `logger.warning_advice()`
							transformers.utils.logging._reset_library_root_logger()

							UpperCAmelCase_    :      Optional[Any]            =						logging.get_logger('transformers.models.bart.tokenization_bart'   )
							UpperCAmelCase_    :      Dict            =						'Testing 1, 2, 3'

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

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





def      lowercase__      (     ):


					'''simple docstring'''


					disable_progress_bar()
					assert are_progress_bars_disabled()

					enable_progress_bar()
					assert not are_progress_bars_disabled()














from typing import List

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


__UpperCAmelCase								=						logging.get_logger(__name__)

__UpperCAmelCase								=						{
    'snap-research/efficientformer-l1-300': (
        'https://huggingface.co/snap-research/efficientformer-l1-300/resolve/main/config.json'
    ),
}



class   lowerCamelCase      (_snake_case			):







		'''simple docstring'''



		_snake_case    :    Optional[int]       						=  '''efficientformer'''



		def __init__(							self				,		_UpperCamelCase = [3, 2, 6, 4]				,		_UpperCamelCase = [4_8, 9_6, 2_2_4, 4_4_8]				,		_UpperCamelCase = [True, True, True, True]				,		_UpperCamelCase = 4_4_8				,		_UpperCamelCase = 3_2				,		_UpperCamelCase = 4				,		_UpperCamelCase = 7				,		_UpperCamelCase = 5				,		_UpperCamelCase = 8				,		_UpperCamelCase = 4				,		_UpperCamelCase = 0.0				,		_UpperCamelCase = 1_6				,		_UpperCamelCase = 3				,		_UpperCamelCase = 3				,		_UpperCamelCase = 3				,		_UpperCamelCase = 2				,		_UpperCamelCase = 1				,		_UpperCamelCase = 0.0				,		_UpperCamelCase = 1				,		_UpperCamelCase = True				,		_UpperCamelCase = True				,		_UpperCamelCase = 1E-5				,		_UpperCamelCase = "gelu"				,		_UpperCamelCase = 0.02				,		_UpperCamelCase = 1E-12				,		_UpperCamelCase = 2_2_4				,		_UpperCamelCase = 1E-05				,		**_UpperCamelCase				,		)	->							None:
							super().__init__(**_UpperCamelCase   )

							UpperCAmelCase_    :      int            =						hidden_act
							UpperCAmelCase_    :      Union[str, Any]            =						hidden_dropout_prob
							UpperCAmelCase_    :      Tuple            =						hidden_sizes
							UpperCAmelCase_    :      Union[str, Any]            =						num_hidden_layers
							UpperCAmelCase_    :      List[str]            =						num_attention_heads
							UpperCAmelCase_    :      List[Any]            =						initializer_range
							UpperCAmelCase_    :      int            =						layer_norm_eps
							UpperCAmelCase_    :      List[str]            =						patch_size
							UpperCAmelCase_    :      Union[str, Any]            =						num_channels
							UpperCAmelCase_    :      Optional[Any]            =						depths
							UpperCAmelCase_    :      List[Any]            =						mlp_expansion_ratio
							UpperCAmelCase_    :      List[str]            =						downsamples
							UpperCAmelCase_    :      List[Any]            =						dim
							UpperCAmelCase_    :      Tuple            =						key_dim
							UpperCAmelCase_    :      Optional[int]            =						attention_ratio
							UpperCAmelCase_    :      str            =						resolution
							UpperCAmelCase_    :      Dict            =						pool_size
							UpperCAmelCase_    :      Union[str, Any]            =						downsample_patch_size
							UpperCAmelCase_    :      List[str]            =						downsample_stride
							UpperCAmelCase_    :      List[str]            =						downsample_pad
							UpperCAmelCase_    :      Any            =						drop_path_rate
							UpperCAmelCase_    :      Dict            =						num_metaad_blocks
							UpperCAmelCase_    :      Dict            =						distillation
							UpperCAmelCase_    :      int            =						use_layer_scale
							UpperCAmelCase_    :      Any            =						layer_scale_init_value
							UpperCAmelCase_    :      Any            =						image_size
							UpperCAmelCase_    :      Dict            =						batch_norm_eps






