





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


UpperCAmelCase_     							= DUMMY_UNKNOWN_IDENTIFIER
# An actual model hosted on huggingface.co

UpperCAmelCase_     							= 'main'
# Default branch name
UpperCAmelCase_     							= 'f2c752cfc5c0ab6f4bdec59acea69eefbee381c2'
# One particular commit (not the top of `main`)
UpperCAmelCase_     							= 'aaaaaaa'
# This commit does not exist, so we should 404.

UpperCAmelCase_     							= 'd9e9f15bc825e4b2c9249e9578f884bbcb5e3684'
# Sha-1 of config.json on the top of `main`, for checking purposes
UpperCAmelCase_     							= '4b243c475af8d0a7754e87d7d096c92e5199ec2fe168a2ee7998e3b8e9bcb1d3'




@contextlib.contextmanager
def 		lowerCAmelCase_    (  )      ->	str:
    print('''Welcome!'''      )
    yield
    print('''Bye!'''      )




@contextlib.contextmanager
def 		lowerCAmelCase_    (  )      ->	Tuple:
    print('''Bonjour!'''      )
    yield
    print('''Au revoir!'''      )






class     lowercase__       (	unittest.TestCase				):

   '''simple docstring'''


   def       UpperCamelCase__  (    self							) ->      Any:






       """simple docstring"""
       # If the spec is missing, importlib would not be able to import the module dynamically.
       assert transformers.__spec__ is not None
       assert importlib.util.find_spec('''transformers'''							) is not None






class     lowercase__       (	unittest.TestCase				):

   '''simple docstring'''


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






       """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       UpperCamelCase__  (    self,		__magic_name__							) ->      List[str]:






       """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       UpperCamelCase__  (    self,		__magic_name__							) ->      List[Any]:






       """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       UpperCamelCase__  (    self							) ->      Tuple:






       """simple docstring"""
       self.assertEqual(find_labels(__magic_name__							),		['''labels''']							)
       self.assertEqual(find_labels(__magic_name__							),		['''labels''', '''next_sentence_label''']							)
       self.assertEqual(find_labels(__magic_name__							),		['''start_positions''', '''end_positions''']							)






       class     lowercase__       (	__lowerCamelCase				):

          '''simple docstring'''


          pass




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




   @require_tf
   def       UpperCamelCase__  (    self							) ->      Optional[int]:






       """simple docstring"""
       self.assertEqual(find_labels(__magic_name__							),		['''labels''']							)
       self.assertEqual(find_labels(__magic_name__							),		['''labels''', '''next_sentence_label''']							)
       self.assertEqual(find_labels(__magic_name__							),		['''start_positions''', '''end_positions''']							)






       class     lowercase__       (	__lowerCamelCase				):

          '''simple docstring'''


          pass




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




   @require_flax
   def       UpperCamelCase__  (    self							) ->      str:






       """simple docstring"""
       # Flax models don't have labels
       self.assertEqual(find_labels(__magic_name__							),		[]							)
       self.assertEqual(find_labels(__magic_name__							),		[]							)
       self.assertEqual(find_labels(__magic_name__							),		[]							)






       class     lowercase__       (	__lowerCamelCase				):

          '''simple docstring'''


          pass




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








from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase_     							= logging.get_logger(__name__)

UpperCAmelCase_     							= {
    'google/mobilenet_v2_1.4_224': 'https://huggingface.co/google/mobilenet_v2_1.4_224/resolve/main/config.json',
    'google/mobilenet_v2_1.0_224': 'https://huggingface.co/google/mobilenet_v2_1.0_224/resolve/main/config.json',
    'google/mobilenet_v2_0.75_160': 'https://huggingface.co/google/mobilenet_v2_0.75_160/resolve/main/config.json',
    'google/mobilenet_v2_0.35_96': 'https://huggingface.co/google/mobilenet_v2_0.35_96/resolve/main/config.json',
    # See all MobileNetV2 models at https://huggingface.co/models?filter=mobilenet_v2
}






class     lowercase__       (	__lowerCamelCase				):

   '''simple docstring'''


   a						:							List[str]   		=		"mobilenet_v2"




   def __init__(    self,		__magic_name__=3,		__magic_name__=224,		__magic_name__=1.0,		__magic_name__=8,		__magic_name__=8,		__magic_name__=6,		__magic_name__=32,		__magic_name__=True,		__magic_name__=True,		__magic_name__="relu6",		__magic_name__=True,		__magic_name__=0.8,		__magic_name__=0.02,		__magic_name__=0.001,		__magic_name__=255,		**__magic_name__,		) ->      List[Any]:






       """simple docstring"""
       super().__init__(**__magic_name__							)

       if depth_multiplier <= 0:
           raise ValueError('''depth_multiplier must be greater than zero.'''							)

       UpperCamelCase__							:				Union[str, Any]          =      num_channels
       UpperCamelCase__							:				int          =      image_size
       UpperCamelCase__							:				int          =      depth_multiplier
       UpperCamelCase__							:				Tuple          =      depth_divisible_by
       UpperCamelCase__							:				List[str]          =      min_depth
       UpperCamelCase__							:				Optional[int]          =      expand_ratio
       UpperCamelCase__							:				Optional[int]          =      output_stride
       UpperCamelCase__							:				Tuple          =      first_layer_is_expansion
       UpperCamelCase__							:				Union[str, Any]          =      finegrained_output
       UpperCamelCase__							:				str          =      hidden_act
       UpperCamelCase__							:				Optional[Any]          =      tf_padding
       UpperCamelCase__							:				Optional[int]          =      classifier_dropout_prob
       UpperCamelCase__							:				int          =      initializer_range
       UpperCamelCase__							:				Union[str, Any]          =      layer_norm_eps
       UpperCamelCase__							:				Tuple          =      semantic_loss_ignore_index






class     lowercase__       (	__lowerCamelCase				):

   '''simple docstring'''


   a						:							Union[str, Any]   		=		version.parse("1.11"				)




   @property
   def       UpperCamelCase__  (    self							) ->      Mapping[str, Mapping[int, str]]:






       """simple docstring"""
       return OrderedDict([('''pixel_values''', {0: '''batch'''})]							)




   @property
   def       UpperCamelCase__  (    self							) ->      Mapping[str, Mapping[int, str]]:






       """simple docstring"""
       if self.task == "image-classification":
           return OrderedDict([('''logits''', {0: '''batch'''})]							)
       else:
           return OrderedDict([('''last_hidden_state''', {0: '''batch'''}), ('''pooler_output''', {0: '''batch'''})]							)




   @property
   def       UpperCamelCase__  (    self							) ->      float:






       """simple docstring"""
       return 1E-4

