


"""simple docstring"""



import subprocess
import sys

from transformers import BertConfig, BertModel, BertTokenizer, pipeline
from transformers.testing_utils import TestCasePlus, require_torch
class 					__magic_name__		(			lowercase_     ):






       @require_torch
       def  __snake_case						(   self  :    Optional[Any]				):

              '''simple docstring'''






              lowercase		:Optional[int]       							=				"""
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

              lowercase		:List[str]       							=				"""
mname = \"hf-internal-testing/tiny-random-bert\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
BertTokenizer.from_pretrained(mname)
pipe = pipeline(task=\"fill-mask\", model=mname)
print(\"success\")
        """

              lowercase		:Tuple       							=				"""
import socket
def offline_socket(*args, **kwargs): raise RuntimeError(\"Offline mode is enabled, we shouldn't access internet\")
socket.socket = offline_socket
        """

              # Force fetching the files so that we can use the cache
              lowercase		:List[Any]       							=				"""hf-internal-testing/tiny-random-bert"""
              BertConfig.from_pretrained(lowerCamelCase_				)
              BertModel.from_pretrained(lowerCamelCase_				)
              BertTokenizer.from_pretrained(lowerCamelCase_				)
              pipeline(task='''fill-mask'''  ,     model=lowerCamelCase_				)

              # baseline - just load from_pretrained with normal network
              lowercase		:List[Any]       							=				[sys.executable, """-c""", """\n""".join([load, run, mock]				)]

              # should succeed
              lowercase		:List[Any]       							=				self.get_env()
              # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
              lowercase		:Optional[Any]       							=				"""1"""
              lowercase		:List[str]       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     0  ,     result.stderr				)
              self.assertIn('''success'''  ,     result.stdout.decode()				)






       @require_torch
       def  __snake_case						(   self  :    List[str]				):

              '''simple docstring'''






              lowercase		:List[str]       							=				"""
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

              lowercase		:int       							=				"""
mname = \"hf-internal-testing/tiny-random-bert\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
BertTokenizer.from_pretrained(mname)
pipe = pipeline(task=\"fill-mask\", model=mname)
print(\"success\")
        """

              lowercase		:Any       							=				"""
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Faking flaky internet\")
socket.socket = offline_socket
        """

              # Force fetching the files so that we can use the cache
              lowercase		:Any       							=				"""hf-internal-testing/tiny-random-bert"""
              BertConfig.from_pretrained(lowerCamelCase_				)
              BertModel.from_pretrained(lowerCamelCase_				)
              BertTokenizer.from_pretrained(lowerCamelCase_				)
              pipeline(task='''fill-mask'''  ,     model=lowerCamelCase_				)

              # baseline - just load from_pretrained with normal network
              lowercase		:str       							=				[sys.executable, """-c""", """\n""".join([load, run, mock]				)]

              # should succeed
              lowercase		:List[Any]       							=				self.get_env()
              lowercase		:Optional[Any]       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     0  ,     result.stderr				)
              self.assertIn('''success'''  ,     result.stdout.decode()				)






       @require_torch
       def  __snake_case						(   self  :    List[str]				):

              '''simple docstring'''






              lowercase		:int       							=				"""
from transformers import BertConfig, BertModel, BertTokenizer
        """

              lowercase		:Any       							=				"""
mname = \"hf-internal-testing/tiny-random-bert-sharded\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
print(\"success\")
        """

              lowercase		:Optional[Any]       							=				"""
import socket
def offline_socket(*args, **kwargs): raise ValueError(\"Offline mode is enabled\")
socket.socket = offline_socket
        """

              # baseline - just load from_pretrained with normal network
              lowercase		:Optional[Any]       							=				[sys.executable, """-c""", """\n""".join([load, run]				)]

              # should succeed
              lowercase		:Union[str, Any]       							=				self.get_env()
              lowercase		:Any       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     0  ,     result.stderr				)
              self.assertIn('''success'''  ,     result.stdout.decode()				)

              # next emulate no network
              lowercase		:Tuple       							=				[sys.executable, """-c""", """\n""".join([load, mock, run]				)]

              # Doesn't fail anymore since the model is in the cache due to other tests, so commenting this.
              # env["TRANSFORMERS_OFFLINE"] = "0"
              # result = subprocess.run(cmd, env=env, check=False, capture_output=True)
              # self.assertEqual(result.returncode, 1, result.stderr)

              # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
              lowercase		:Tuple       							=				"""1"""
              lowercase		:Optional[int]       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     0  ,     result.stderr				)
              self.assertIn('''success'''  ,     result.stdout.decode()				)






       @require_torch
       def  __snake_case						(   self  :    Dict				):

              '''simple docstring'''






              lowercase		:Any       							=				"""
from transformers import pipeline
        """
              lowercase		:Union[str, Any]       							=				"""
mname = \"hf-internal-testing/tiny-random-bert\"
pipe = pipeline(model=mname)
        """

              lowercase		:List[Any]       							=				"""
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")
socket.socket = offline_socket
        """
              lowercase		:List[Any]       							=				self.get_env()
              lowercase		:Union[str, Any]       							=				"""1"""
              lowercase		:Union[str, Any]       							=				[sys.executable, """-c""", """\n""".join([load, mock, run]				)]
              lowercase		:List[Any]       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     1  ,     result.stderr				)
              self.assertIn(
                  '''You cannot infer task automatically within `pipeline` when using offline mode'''  ,     result.stderr.decode().replace('''\n'''  ,     ''''''				)  ,     )







       @require_torch
       def  __snake_case						(   self  :    Any				):

              '''simple docstring'''






              lowercase		:Any       							=				"""
from transformers import AutoModel
        """
              lowercase		:Dict       							=				"""
mname = \"hf-internal-testing/test_dynamic_model\"
AutoModel.from_pretrained(mname, trust_remote_code=True)
print(\"success\")
        """

              # baseline - just load from_pretrained with normal network
              lowercase		:str       							=				[sys.executable, """-c""", """\n""".join([load, run]				)]

              # should succeed
              lowercase		:Optional[int]       							=				self.get_env()
              lowercase		:int       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     0  ,     result.stderr				)
              self.assertIn('''success'''  ,     result.stdout.decode()				)

              # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
              lowercase		:str       							=				"""1"""
              lowercase		:Union[str, Any]       							=				subprocess.run(lowerCamelCase_  ,     env=lowerCamelCase_  ,     check=lowerCamelCase_  ,     capture_output=lowerCamelCase_				)
              self.assertEqual(result.returncode  ,     0  ,     result.stderr				)
              self.assertIn('''success'''  ,     result.stdout.decode()				)





"""simple docstring"""



UpperCAmelCase      		=			{str(digit): digit**5 for digit in range(10)}






def       lowerCamelCase					(a_						:int)     ->							int:
       return sum(DIGITS_FIFTH_POWER[digit] for digit in str(a_))






def       lowerCamelCase					()     ->							int:
       return sum(
           number
           for number in range(1000				,				100_0000)
           if number == digits_fifth_powers_sum(a_))


if __name__ == "__main__":
 print(solution())

