




'''simple docstring'''


import contextlib
import importlib
import io
import unittest

import transformers

# Try to import everything from transformers to ensure every object can be loaded.
from transformers import *  # noqa F406
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch
from transformers.utils import ContextManagers, find_labels, is_flax_available, is_tf_available, is_torch_available


if is_torch_available():
				from transformers import BertForPreTraining, BertForQuestionAnswering, BertForSequenceClassification

if is_tf_available():
				from transformers import TFBertForPreTraining, TFBertForQuestionAnswering, TFBertForSequenceClassification

if is_flax_available():
				from transformers import FlaxBertForPreTraining, FlaxBertForQuestionAnswering, FlaxBertForSequenceClassification


_snake_case : List[str]  				=						DUMMY_UNKNOWN_IDENTIFIER
# An actual model hosted on huggingface.co

_snake_case : Union[str, Any]  				=						'main'
# Default branch name
_snake_case : Dict  				=						'f2c752cfc5c0ab6f4bdec59acea69eefbee381c2'
# One particular commit (not the top of `main`)
_snake_case : Dict  				=						'aaaaaaa'
# This commit does not exist, so we should 404.

_snake_case : str  				=						'd9e9f15bc825e4b2c9249e9578f884bbcb5e3684'
# Sha-1 of config.json on the top of `main`, for checking purposes
_snake_case : int  				=						'4b243c475af8d0a7754e87d7d096c92e5199ec2fe168a2ee7998e3b8e9bcb1d3'
@contextlib.contextmanager
def 						snake_case_       ():





							'''simple docstring'''


							print('''Welcome!''' )
							yield
							print('''Bye!''' )
@contextlib.contextmanager
def 						snake_case_       ():





							'''simple docstring'''


							print('''Bonjour!''' )
							yield
							print('''Au revoir!''' )

class      A       (						unittest.TestCase       ):







							def   __lowerCAmelCase     (    self			:    Dict   )     ->				Union[str, Any]:


														"""simple docstring"""


														assert transformers.__spec__ is not None
														assert importlib.util.find_spec('''transformers'''   ) is not None



class      A       (						unittest.TestCase       ):







							@unittest.mock.patch('''sys.stdout'''				,     new_callable=io.StringIO   )
							def   __lowerCAmelCase     (    self			:    str				,     lowerCAmelCase_			:    str   )     ->				int:


														"""simple docstring"""


														with ContextManagers([]   ):
																					print('''Transformers are awesome!'''   )
														# The print statement adds a new line at the end of the output
														self.assertEqual(mock_stdout.getvalue()				,     '''Transformers are awesome!\n'''   )







							@unittest.mock.patch('''sys.stdout'''				,     new_callable=io.StringIO   )
							def   __lowerCAmelCase     (    self			:    Any				,     lowerCAmelCase_			:    Optional[int]   )     ->				Any:


														"""simple docstring"""


														with ContextManagers([context_en()]   ):
																					print('''Transformers are awesome!'''   )
														# The output should be wrapped with an English welcome and goodbye
														self.assertEqual(mock_stdout.getvalue()				,     '''Welcome!\nTransformers are awesome!\nBye!\n'''   )







							@unittest.mock.patch('''sys.stdout'''				,     new_callable=io.StringIO   )
							def   __lowerCAmelCase     (    self			:    Optional[Any]				,     lowerCAmelCase_			:    List[Any]   )     ->				str:


														"""simple docstring"""


														with ContextManagers([context_fr(), context_en()]   ):
																					print('''Transformers are awesome!'''   )
														# The output should be wrapped with an English and French welcome and goodbye
														self.assertEqual(mock_stdout.getvalue()				,     '''Bonjour!\nWelcome!\nTransformers are awesome!\nBye!\nAu revoir!\n'''   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    int   )     ->				Optional[int]:


														"""simple docstring"""


														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''labels''']   )
														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''labels''', '''next_sentence_label''']   )
														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''start_positions''', '''end_positions''']   )

														class      A       (						_a       ):
																					pass



														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''labels''']   )







							@require_tf
							def   __lowerCAmelCase     (    self			:    Tuple   )     ->				Optional[Any]:


														"""simple docstring"""


														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''labels''']   )
														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''labels''', '''next_sentence_label''']   )
														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''start_positions''', '''end_positions''']   )

														class      A       (						_a       ):
																					pass



														self.assertEqual(find_labels(lowerCAmelCase_   )				,     ['''labels''']   )







							@require_flax
							def   __lowerCAmelCase     (    self			:    int   )     ->				Dict:


														"""simple docstring"""


														self.assertEqual(find_labels(lowerCAmelCase_   )				,     []   )
														self.assertEqual(find_labels(lowerCAmelCase_   )				,     []   )
														self.assertEqual(find_labels(lowerCAmelCase_   )				,     []   )

														class      A       (						_a       ):
																					pass



														self.assertEqual(find_labels(lowerCAmelCase_   )				,     []   )



"""simple docstring"""
from typing import List

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


SCREAMING_SNAKE_CASE_					     =	logging.get_logger(__name__)

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



							'''simple docstring'''





							_snake_case						      =		'''efficientformer'''




							def __init__( self    ,				snake_case_ = [3, 2, 6, 4]    ,				snake_case_ = [48, 96, 224, 448]    ,				snake_case_ = [True, True, True, True]    ,				snake_case_ = 448    ,				snake_case_ = 32    ,				snake_case_ = 4    ,				snake_case_ = 7    ,				snake_case_ = 5    ,				snake_case_ = 8    ,				snake_case_ = 4    ,				snake_case_ = 0.0    ,				snake_case_ = 16    ,				snake_case_ = 3    ,				snake_case_ = 3    ,				snake_case_ = 3    ,				snake_case_ = 2    ,				snake_case_ = 1    ,				snake_case_ = 0.0    ,				snake_case_ = 1    ,				snake_case_ = True    ,				snake_case_ = True    ,				snake_case_ = 1e-5    ,				snake_case_ = "gelu"    ,				snake_case_ = 0.02    ,				snake_case_ = 1e-1_2    ,				snake_case_ = 224    ,				snake_case_ = 1e-0_5    ,				**snake_case_    ,				)       ->  None:
													super().__init__(**snake_case_				)

													__lowerCAmelCase     =  hidden_act
													__lowerCAmelCase     =  hidden_dropout_prob
													__lowerCAmelCase     =  hidden_sizes
													__lowerCAmelCase     =  num_hidden_layers
													__lowerCAmelCase     =  num_attention_heads
													__lowerCAmelCase     =  initializer_range
													__lowerCAmelCase     =  layer_norm_eps
													__lowerCAmelCase     =  patch_size
													__lowerCAmelCase     =  num_channels
													__lowerCAmelCase     =  depths
													__lowerCAmelCase     =  mlp_expansion_ratio
													__lowerCAmelCase     =  downsamples
													__lowerCAmelCase     =  dim
													__lowerCAmelCase     =  key_dim
													__lowerCAmelCase     =  attention_ratio
													__lowerCAmelCase     =  resolution
													__lowerCAmelCase     =  pool_size
													__lowerCAmelCase     =  downsample_patch_size
													__lowerCAmelCase     =  downsample_stride
													__lowerCAmelCase     =  downsample_pad
													__lowerCAmelCase     =  drop_path_rate
													__lowerCAmelCase     =  num_metaad_blocks
													__lowerCAmelCase     =  distillation
													__lowerCAmelCase     =  use_layer_scale
													__lowerCAmelCase     =  layer_scale_init_value
													__lowerCAmelCase     =  image_size
													__lowerCAmelCase     =  batch_norm_eps
