






import json
import os
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path

from requests.exceptions import HTTPError

from transformers.utils import (
    CONFIG_NAME,
    FLAX_WEIGHTS_NAME,
    TF2_WEIGHTS_NAME,
    TRANSFORMERS_CACHE,
    WEIGHTS_NAME,
    cached_file,
    get_file_from_repo,
    has_file,
)


a						:			Optional[int]     	=					"hf-internal-testing/tiny-random-bert"
a						:			Union[str, Any]     	=					os.path.join(TRANSFORMERS_CACHE, "models--hf-internal-testing--tiny-random-bert")
a						:			Optional[int]     	=					"9b8c223d42b2188cb49d29af482996f9d0f3e5a6"
class        a       (					unittest.TestCase  ):



      """simple docstring"""


      def       UpperCAmelCase ( self   :     Union[str, Any]   )				-> Union[str, Any]:
        __UpperCAmelCase				:      str	 =    cached_file(__lowercase						, __lowercase   )
        # Should have downloaded the file in here
        self.assertTrue(os.path.isdir(__lowercase   )   )
        # Cache should contain at least those three subfolders:
        for subfolder in ["blobs", "refs", "snapshots"]:
          self.assertTrue(os.path.isdir(os.path.join(__lowercase						, __lowercase   )   )   )
        with open(os.path.join(__lowercase						, """refs"""						, """main"""   )   ) as f:
          __UpperCAmelCase				:      List[str]	 =    f.read()
        self.assertEqual(__lowercase						, os.path.join(__lowercase						, """snapshots"""						, __lowercase						, __lowercase   )   )
        self.assertTrue(os.path.isfile(__lowercase   )   )

        # File is cached at the same place the second time.
        __UpperCAmelCase				:      Tuple	 =    cached_file(__lowercase						, __lowercase   )
        self.assertEqual(__lowercase						, __lowercase   )

        # Using a specific revision to test the full commit hash.
        __UpperCAmelCase				:      Union[str, Any]	 =    cached_file(__lowercase						, __lowercase						, revision="""9b8c223"""   )
        self.assertEqual(__lowercase						, os.path.join(__lowercase						, """snapshots"""						, __lowercase						, __lowercase   )   )
      def       UpperCAmelCase ( self   :     List[Any]   )				-> List[str]:
        with self.assertRaisesRegex(__lowercase						, """is not a valid model identifier"""   ):
          __UpperCAmelCase				:      Optional[int]	 =    cached_file("""tiny-random-bert"""						, __lowercase   )

        with self.assertRaisesRegex(__lowercase						, """is not a valid git identifier"""   ):
          __UpperCAmelCase				:      Tuple	 =    cached_file(__lowercase						, __lowercase						, revision="""aaaa"""   )

        with self.assertRaisesRegex(__lowercase						, """does not appear to have a file named"""   ):
          __UpperCAmelCase				:      Optional[int]	 =    cached_file(__lowercase						, """conf"""   )
      def       UpperCAmelCase ( self   :     Any   )				-> List[Any]:
        with self.assertRaisesRegex(__lowercase						, """does not appear to have a file named"""   ):
          __UpperCAmelCase				:      Union[str, Any]	 =    cached_file(__lowercase						, """conf"""   )

        with open(os.path.join(__lowercase						, """refs"""						, """main"""   )   ) as f:
          __UpperCAmelCase				:      Any	 =    f.read()
        self.assertTrue(os.path.isfile(os.path.join(__lowercase						, """.no_exist"""						, __lowercase						, """conf"""   )   )   )

        __UpperCAmelCase				:      List[Any]	 =    cached_file(__lowercase						, """conf"""						, _raise_exceptions_for_missing_entries=__lowercase   )
        self.assertIsNone(__lowercase   )

        __UpperCAmelCase				:      Optional[int]	 =    cached_file(__lowercase						, """conf"""						, local_files_only=__lowercase						, _raise_exceptions_for_missing_entries=__lowercase   )
        self.assertIsNone(__lowercase   )

        __UpperCAmelCase				:      Dict	 =    mock.Mock()
        __UpperCAmelCase				:      Optional[int]	 =    500
        __UpperCAmelCase				:      int	 =    {}
        __UpperCAmelCase				:      Optional[int]	 =    HTTPError
        __UpperCAmelCase				:      List[str]	 =    {}

        # Under the mock environment we get a 500 error when trying to reach the tokenizer.
        with mock.patch("""requests.Session.request"""						, return_value=__lowercase   ) as mock_head:
          __UpperCAmelCase				:      Dict	 =    cached_file(__lowercase						, """conf"""						, _raise_exceptions_for_connection_errors=__lowercase   )
          self.assertIsNone(__lowercase   )
          # This check we did call the fake head request
          mock_head.assert_called()
      def       UpperCAmelCase ( self   :     List[str]   )				-> int:
        self.assertTrue(has_file("""hf-internal-testing/tiny-bert-pt-only"""						, __lowercase   )   )
        self.assertFalse(has_file("""hf-internal-testing/tiny-bert-pt-only"""						, __lowercase   )   )
        self.assertFalse(has_file("""hf-internal-testing/tiny-bert-pt-only"""						, __lowercase   )   )
      def       UpperCAmelCase ( self   :     str   )				-> List[str]:
        # `get_file_from_repo` returns None if the file does not exist
        self.assertIsNone(get_file_from_repo("""bert-base-cased"""						, """ahah.txt"""   )   )

        # The function raises if the repository does not exist.
        with self.assertRaisesRegex(__lowercase						, """is not a valid model identifier"""   ):
          get_file_from_repo("""bert-base-case"""						, __lowercase   )

        # The function raises if the revision does not exist.
        with self.assertRaisesRegex(__lowercase						, """is not a valid git identifier"""   ):
          get_file_from_repo("""bert-base-cased"""						, __lowercase						, revision="""ahaha"""   )

        __UpperCAmelCase				:      Union[str, Any]	 =    get_file_from_repo("""bert-base-cased"""						, __lowercase   )
        # The name is the cached name which is not very easy to test, so instead we load the content.
        __UpperCAmelCase				:      Optional[int]	 =    json.loads(open(__lowercase						, """r"""   ).read()   )
        self.assertEqual(config["""hidden_size"""]						, 768   )




      def       UpperCAmelCase ( self   :     List[Any]   )				-> Any:
        with tempfile.TemporaryDirectory() as tmp_dir:
          __UpperCAmelCase				:      Optional[int]	 =    Path(__lowercase   ) / """a.txt"""
          filename.touch()
          self.assertEqual(get_file_from_repo(__lowercase						, """a.txt"""   )						, str(__lowercase   )   )

          self.assertIsNone(get_file_from_repo(__lowercase						, """b.txt"""   )   )






def 						_lowerCAmelCase							(     _lowerCAmelCase = 1000			)    ->						int:


						'''simple docstring'''






						__snake_case				=		2**power
						__snake_case				=		str(_lowerCAmelCase			)
						__snake_case				=		list(_lowerCAmelCase			)
						__snake_case				=		0

						for i in list_num:
												sum_of_num += int(_lowerCAmelCase			)

						return sum_of_num


if __name__ == "__main__":
	A				:       Optional[Any]      =  int(input('Enter the power of 2: ').strip())
	print('2 ^ ', power, ' = ', 2**power)
	A				:       List[Any]      =  solution(power)
	print('Sum of the digits is: ', result)





