from string import ascii_uppercase

_lowerCAmelCase       =		{str(ord(c) - 55): c for c in ascii_uppercase}
def 					_snake_case	(  __snake_case  ,     __snake_case						):
					if isinstance(__snake_case  ,     __snake_case						):
										raise TypeError('''int() can\'t convert non-string with explicit base'''						)
					if num < 0:
										raise ValueError('''parameter must be positive int'''						)
					if isinstance(__snake_case  ,     __snake_case						):
										raise TypeError('''\'str\' object cannot be interpreted as an integer'''						)
					if isinstance(__snake_case  ,     __snake_case						):
										raise TypeError('''\'float\' object cannot be interpreted as an integer'''						)
					if base in (0, 1):
										raise ValueError('''base must be >= 2'''						)
					if base > 36:
										raise ValueError('''base must be <= 36'''						)
					_UpperCamelCase			     =     ''''''
					_UpperCamelCase			     =     0
					_UpperCamelCase			     =     0
					while div != 1:
										_UpperCamelCase     ,    _UpperCamelCase			     =     divmod(__snake_case  ,     __snake_case						)
										if base >= 11 and 9 < mod < 36:
															_UpperCamelCase			     =     ALPHABET_VALUES[str(__snake_case						)]
										else:
															_UpperCamelCase			     =     str(__snake_case						)
										new_value += actual_value
										_UpperCamelCase			     =     num // base
										_UpperCamelCase			     =     div
										if div == 0:
															return str(new_value[::-1]						)
										elif div == 1:
															new_value += str(__snake_case						)
															return str(new_value[::-1]						)

					return new_value[::-1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for base in range(2, 37):
										for num in range(1_000):
															assert int(decimal_to_any(num, base), base) == num, (
															    num,
															    base,
															    decimal_to_any(num, base),
															    int(decimal_to_any(num, base), base),
															)

import importlib
import json
import os
import sys
import tempfile
import unittest
from pathlib import Path

import transformers
import transformers.models.auto
from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig
from transformers.models.bert.configuration_bert import BertConfig
from transformers.models.roberta.configuration_roberta import RobertaConfig
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, get_tests_dir


sys.path.append(str(Path(__file__).parent.parent.parent.parent / '''utils'''))

from test_module.custom_configuration import CustomConfig  # noqa E402


UpperCAmelCase_           =				get_tests_dir('''fixtures/dummy-config.json''')




class 			__magic_name__	(		unittest.TestCase     ):





   """simple docstring"""




   def 	lowerCAmelCase    (						self       :	str				):



    """simple docstring"""



    _UpperCamelCase:  Dict    						=			0



   def 	lowerCAmelCase    (						self       :	Any				):



    """simple docstring"""



    self.assertIsNotNone(transformers.models.auto.__spec__				)
    self.assertIsNotNone(importlib.util.find_spec('''transformers.models.auto'''				)				)



   def 	lowerCAmelCase    (						self       :	Union[str, Any]				):



    """simple docstring"""



    _UpperCamelCase:  List[str]    						=			AutoConfig.from_pretrained('''bert-base-uncased'''				)
    self.assertIsInstance(_lowercase		,	_lowercase				)



   def 	lowerCAmelCase    (						self       :	int				):



    """simple docstring"""



    _UpperCamelCase:  int    						=			AutoConfig.from_pretrained(_lowercase				)
    self.assertIsInstance(_lowercase		,	_lowercase				)



   def 	lowerCAmelCase    (						self       :	List[Any]				):



    """simple docstring"""



    _UpperCamelCase:  List[Any]    						=			AutoConfig.from_pretrained(_lowercase				)
    self.assertIsInstance(_lowercase		,	_lowercase				)



   def 	lowerCAmelCase    (						self       :	Optional[int]				):



    """simple docstring"""



    _UpperCamelCase:  List[str]    						=			AutoConfig.for_model('''roberta'''				)
    self.assertIsInstance(_lowercase		,	_lowercase				)



   def 	lowerCAmelCase    (						self       :	List[str]				):



    """simple docstring"""



    with tempfile.TemporaryDirectory() as tmp_dir:
     # This model name contains bert and roberta, but roberta ends up being picked.
     _UpperCamelCase:  Union[str, Any]    						=			os.path.join(_lowercase		,	'''fake-roberta'''				)
     os.makedirs(_lowercase		,	exist_ok=_lowercase				)
     with open(os.path.join(_lowercase		,	'''config.json'''				)		,	'''w'''				) as f:
      f.write(json.dumps({}				)				)
     _UpperCamelCase:  Union[str, Any]    						=			AutoConfig.from_pretrained(_lowercase				)
     self.assertEqual(type(_lowercase				)		,	_lowercase				)



   def 	lowerCAmelCase    (						self       :	Dict				):



    """simple docstring"""



    try:
     AutoConfig.register('''custom'''		,	_lowercase				)
     # Wrong model type will raise an error
     with self.assertRaises(_lowercase				):
      AutoConfig.register('''model'''		,	_lowercase				)
     # Trying to register something existing in the Transformers library will raise an error
     with self.assertRaises(_lowercase				):
      AutoConfig.register('''bert'''		,	_lowercase				)

     # Now that the config is registered, it can be used as any other config with the auto-API
     _UpperCamelCase:  Union[str, Any]    						=			CustomConfig()
     with tempfile.TemporaryDirectory() as tmp_dir:
      config.save_pretrained(_lowercase				)
      _UpperCamelCase:  Any    						=			AutoConfig.from_pretrained(_lowercase				)
      self.assertIsInstance(_lowercase		,	_lowercase				)

    finally:
     if "custom" in CONFIG_MAPPING._extra_content:
      del CONFIG_MAPPING._extra_content["custom"]



   def 	lowerCAmelCase    (						self       :	Optional[int]				):



    """simple docstring"""



    with self.assertRaisesRegex(
        _lowercase		,	'''bert-base is not a local folder and is not a valid model identifier'''				):
     _UpperCamelCase:  Optional[int]    						=			AutoConfig.from_pretrained('''bert-base'''				)



   def 	lowerCAmelCase    (						self       :	Tuple				):



    """simple docstring"""



    with self.assertRaisesRegex(
        _lowercase		,	R'''aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'''				):
     _UpperCamelCase:  str    						=			AutoConfig.from_pretrained(_lowercase		,	revision='''aaaaaa'''				)



   def 	lowerCAmelCase    (						self       :	Union[str, Any]				):



    """simple docstring"""



    with self.assertRaisesRegex(
        _lowercase		,	'''hf-internal-testing/no-config-test-repo does not appear to have a file named config.json.'''		,	):
     _UpperCamelCase:  int    						=			AutoConfig.from_pretrained('''hf-internal-testing/no-config-test-repo'''				)



   def 	lowerCAmelCase    (						self       :	Dict				):



    """simple docstring"""



    with self.assertRaises(_lowercase				):
     _UpperCamelCase:  List[str]    						=			AutoConfig.from_pretrained('''hf-internal-testing/test_dynamic_model'''				)
    # If remote code is disabled, we can't load this config.
    with self.assertRaises(_lowercase				):
     _UpperCamelCase:  Optional[int]    						=			AutoConfig.from_pretrained('''hf-internal-testing/test_dynamic_model'''		,	trust_remote_code=_lowercase				)

    _UpperCamelCase:  Union[str, Any]    						=			AutoConfig.from_pretrained('''hf-internal-testing/test_dynamic_model'''		,	trust_remote_code=_lowercase				)
    self.assertEqual(config.__class__.__name__		,	'''NewModelConfig'''				)

    # Test config can be reloaded.
    with tempfile.TemporaryDirectory() as tmp_dir:
     config.save_pretrained(_lowercase				)
     _UpperCamelCase:  str    						=			AutoConfig.from_pretrained(_lowercase		,	trust_remote_code=_lowercase				)
    self.assertEqual(reloaded_config.__class__.__name__		,	'''NewModelConfig'''				)



   def 	lowerCAmelCase    (						self       :	Any				):



    """simple docstring"""



    class 			__magic_name__	(		__a     ):





       """simple docstring"""




       lowerCAmelCase   :     List[Any]	      = '''new-model'''

    try:
     AutoConfig.register('''new-model'''		,	_lowercase				)
     # If remote code is not set, the default is to use local
     _UpperCamelCase:  List[Any]    						=			AutoConfig.from_pretrained('''hf-internal-testing/test_dynamic_model'''				)
     self.assertEqual(config.__class__.__name__		,	'''NewModelConfigLocal'''				)

     # If remote code is disabled, we load the local one.
     _UpperCamelCase:  Union[str, Any]    						=			AutoConfig.from_pretrained('''hf-internal-testing/test_dynamic_model'''		,	trust_remote_code=_lowercase				)
     self.assertEqual(config.__class__.__name__		,	'''NewModelConfigLocal'''				)

     # If remote is enabled, we load from the Hub
     _UpperCamelCase:  Any    						=			AutoConfig.from_pretrained('''hf-internal-testing/test_dynamic_model'''		,	trust_remote_code=_lowercase				)
     self.assertEqual(config.__class__.__name__		,	'''NewModelConfig'''				)

    finally:
     if "new-model" in CONFIG_MAPPING._extra_content:
      del CONFIG_MAPPING._extra_content["new-model"]