'''simple docstring'''





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


SCREAMING_SNAKE_CASE_:     Dict  =get_tests_dir('fixtures/dummy-config.json')




class        __A      ( unittest.TestCase	):



    def 					_lowercase						(self    :    List[str] ):
         UpperCAmelCase_           =   0



    def 					_lowercase						(self    :    Union[str, Any] ):
         self.assertIsNotNone(transformers.models.auto.__spec__ )
         self.assertIsNotNone(importlib.util.find_spec("transformers.models.auto" ) )



    def 					_lowercase						(self    :    int ):
         UpperCAmelCase_           =   AutoConfig.from_pretrained("bert-base-uncased" )
         self.assertIsInstance(__a   ,			__a )



    def 					_lowercase						(self    :    Optional[int] ):
         UpperCAmelCase_           =   AutoConfig.from_pretrained(__a )
         self.assertIsInstance(__a   ,			__a )



    def 					_lowercase						(self    :    Optional[Any] ):
         UpperCAmelCase_           =   AutoConfig.from_pretrained(__a )
         self.assertIsInstance(__a   ,			__a )



    def 					_lowercase						(self    :    Tuple ):
         UpperCAmelCase_           =   AutoConfig.for_model("roberta" )
         self.assertIsInstance(__a   ,			__a )



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



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

              # Now that the config is registered, it can be used as any other config with the auto-API
              UpperCAmelCase_           =   CustomConfig()
              with tempfile.TemporaryDirectory() as tmp_dir:
                   config.save_pretrained(__a )
                   UpperCAmelCase_           =   AutoConfig.from_pretrained(__a )
                   self.assertIsInstance(__a   ,			__a )

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



    def 					_lowercase						(self    :    Union[str, Any] ):
         with self.assertRaisesRegex(
             __a   ,			"bert-base is not a local folder and is not a valid model identifier" ):
              UpperCAmelCase_           =   AutoConfig.from_pretrained("bert-base" )



    def 					_lowercase						(self    :    Optional[Any] ):
         with self.assertRaisesRegex(
             __a   ,			r"aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)" ):
              UpperCAmelCase_           =   AutoConfig.from_pretrained(__a   ,			revision="aaaaaa" )



    def 					_lowercase						(self    :    Tuple ):
         with self.assertRaisesRegex(
             __a   ,			"hf-internal-testing/no-config-test-repo does not appear to have a file named config.json."   ,			):
              UpperCAmelCase_           =   AutoConfig.from_pretrained("hf-internal-testing/no-config-test-repo" )



    def 					_lowercase						(self    :    Any ):
         # If remote code is not set, we will time out when asking whether to load the model.
         with self.assertRaises(__a ):
              UpperCAmelCase_           =   AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model" )
         # If remote code is disabled, we can't load this config.
         with self.assertRaises(__a ):
              UpperCAmelCase_           =   AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"   ,			trust_remote_code=__a )

         UpperCAmelCase_           =   AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"   ,			trust_remote_code=__a )
         self.assertEqual(config.__class__.__name__   ,			"NewModelConfig" )

         # Test config can be reloaded.
         with tempfile.TemporaryDirectory() as tmp_dir:
              config.save_pretrained(__a )
              UpperCAmelCase_           =   AutoConfig.from_pretrained(__a   ,			trust_remote_code=__a )
         self.assertEqual(reloaded_config.__class__.__name__   ,			"NewModelConfig" )






    def 					_lowercase						(self    :    Tuple ):




         class        __A      ( UpperCamelCase__	):
             a__       :						str          =  """new-model"""

         try:
              AutoConfig.register("new-model"   ,			__a )
              # If remote code is not set, the default is to use local
              UpperCAmelCase_           =   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_           =   AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"   ,			trust_remote_code=__a )
              self.assertEqual(config.__class__.__name__   ,			"NewModelConfigLocal" )

              # If remote is enabled, we load from the Hub
              UpperCAmelCase_           =   AutoConfig.from_pretrained("hf-internal-testing/test_dynamic_model"   ,			trust_remote_code=__a )
              self.assertEqual(config.__class__.__name__   ,			"NewModelConfig" )

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










from math import asin, atan, cos, radians, sin, sqrt, tan

_snake_case										=       6_3_7_8_1_3_7.0
_snake_case										=       6_3_5_6_7_5_2.3_1_4_2_4_5
_snake_case										=       6378137







def 				lowerCAmelCase_	(     snake_case_,snake_case_,snake_case_,snake_case_     ):
      _A							:     Any			=						(AXIS_A - AXIS_B) / AXIS_A
      _A							:     Optional[int]			=						atan((1 - flattening) * tan(radians(snake_case_     )     )     )
      _A							:     List[str]			=						atan((1 - flattening) * tan(radians(snake_case_     )     )     )
      _A							:     Optional[Any]			=						radians(snake_case_     )
      _A							:     str			=						radians(snake_case_     )
      # Equation
      _A							:     Dict			=						sin((phi_a - phi_a) / 2     )
      _A							:     List[str]			=						sin((lambda_a - lambda_a) / 2     )
      # Square both values
      sin_sq_phi *= sin_sq_phi
      sin_sq_lambda *= sin_sq_lambda
      _A							:     Optional[int]			=						sqrt(sin_sq_phi + (cos(snake_case_     ) * cos(snake_case_     ) * sin_sq_lambda)     )
      return 2 * RADIUS * asin(snake_case_     )


if __name__ == "__main__":
  import doctest

  doctest.testmod()

