import subprocess
import sys

from transformers import BertConfig, BertModel, BertTokenizer, pipeline
from transformers.testing_utils import TestCasePlus, require_torch





class      A							(				_lowerCamelCase     ):


   @require_torch
   def 			lowercase_      (self     :						Optional[int]		)						->				int:
         """simple docstring"""



         UpperCAmelCase__								=  "\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        "

         UpperCAmelCase__								=  "\nmname = \"hf-internal-testing/tiny-random-bert\"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nBertTokenizer.from_pretrained(mname)\npipe = pipeline(task=\"fill-mask\", model=mname)\nprint(\"success\")\n        "

         UpperCAmelCase__								=  "\nimport socket\ndef offline_socket(*args, **kwargs): raise RuntimeError(\"Offline mode is enabled, we shouldn\'t access internet\")\nsocket.socket = offline_socket\n        "

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

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

         # should succeed
         UpperCAmelCase__								=  self.get_env()
         # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
         UpperCAmelCase__								=  "1"
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         self.assertEqual(result.returncode       ,  0       ,  result.stderr		)
         self.assertIn("success"       ,  result.stdout.decode()		)


   @require_torch
   def 			lowercase_      (self     :						str		)						->				List[str]:
         """simple docstring"""



         UpperCAmelCase__								=  "\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        "

         UpperCAmelCase__								=  "\nmname = \"hf-internal-testing/tiny-random-bert\"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nBertTokenizer.from_pretrained(mname)\npipe = pipeline(task=\"fill-mask\", model=mname)\nprint(\"success\")\n        "

         UpperCAmelCase__								=  "\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error(\"Faking flaky internet\")\nsocket.socket = offline_socket\n        "

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

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

         # should succeed
         UpperCAmelCase__								=  self.get_env()
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         self.assertEqual(result.returncode       ,  0       ,  result.stderr		)
         self.assertIn("success"       ,  result.stdout.decode()		)


   @require_torch
   def 			lowercase_      (self     :						Dict		)						->				Dict:
         """simple docstring"""



         UpperCAmelCase__								=  "\nfrom transformers import BertConfig, BertModel, BertTokenizer\n        "

         UpperCAmelCase__								=  "\nmname = \"hf-internal-testing/tiny-random-bert-sharded\"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nprint(\"success\")\n        "

         UpperCAmelCase__								=  "\nimport socket\ndef offline_socket(*args, **kwargs): raise ValueError(\"Offline mode is enabled\")\nsocket.socket = offline_socket\n        "

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

         # should succeed
         UpperCAmelCase__								=  self.get_env()
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         self.assertEqual(result.returncode       ,  0       ,  result.stderr		)
         self.assertIn("success"       ,  result.stdout.decode()		)

         # next emulate no network
         UpperCAmelCase__								=  [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
         UpperCAmelCase__								=  "1"
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         self.assertEqual(result.returncode       ,  0       ,  result.stderr		)
         self.assertIn("success"       ,  result.stdout.decode()		)


   @require_torch
   def 			lowercase_      (self     :						List[str]		)						->				str:
         """simple docstring"""



         UpperCAmelCase__								=  "\nfrom transformers import pipeline\n        "
         UpperCAmelCase__								=  "\nmname = \"hf-internal-testing/tiny-random-bert\"\npipe = pipeline(model=mname)\n        "

         UpperCAmelCase__								=  "\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")\nsocket.socket = offline_socket\n        "
         UpperCAmelCase__								=  self.get_env()
         UpperCAmelCase__								=  "1"
         UpperCAmelCase__								=  [sys.executable, "-c", "\n".join([load, mock, run]		)]
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         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 			lowercase_      (self     :						str		)						->				Dict:
         """simple docstring"""



         UpperCAmelCase__								=  "\nfrom transformers import AutoModel\n        "
         UpperCAmelCase__								=  "\nmname = \"hf-internal-testing/test_dynamic_model\"\nAutoModel.from_pretrained(mname, trust_remote_code=True)\nprint(\"success\")\n        "

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

         # should succeed
         UpperCAmelCase__								=  self.get_env()
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         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
         UpperCAmelCase__								=  "1"
         UpperCAmelCase__								=  subprocess.run(_UpperCamelCase       ,  env=_UpperCamelCase       ,  check=_UpperCamelCase       ,  capture_output=_UpperCamelCase		)
         self.assertEqual(result.returncode       ,  0       ,  result.stderr		)
         self.assertIn("success"       ,  result.stdout.decode()		)










from __future__ import annotations

from collections.abc import Iterable, Iterator
from dataclasses import dataclass

snake_case__					:							Union[str, Any]													=     (3, 9, -11, 0, 7, 5, 1, -1)
snake_case__					:							int													=     (4, 6, 2, 0, 8, 10, 3, -2)





@dataclass
class A_					:
   lowerCAmelCase__        = 42
   lowerCAmelCase__        = 42





class A_					:




   def __init__(self	:Dict    ,   _UpperCamelCase	:Iterable[int] )->					None:
         __A          =				None
         for i in sorted(_UpperCamelCase    ,   reverse=_UpperCamelCase ):
               __A          =				Node(_UpperCamelCase    ,   self.head )




   def __iter__(self	:List[str] )->					Iterator[int]:
         __A          =				self.head
         while node:
               yield node.data
               __A          =				node.next_node




   def __len__(self	:Union[str, Any] )->					int:
         return sum(1 for _ in self )






   def __str__(self	:List[Any] )->					str:
         return " -> ".join([str(_UpperCamelCase ) for node in self] )





def _a				(	lowerCamelCase:   SortedLinkedList					,				lowerCamelCase:   SortedLinkedList )	->						SortedLinkedList:







      '''simple docstring'''






      return SortedLinkedList(list(lowerCamelCase ) + list(lowerCamelCase ) )


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       snake_case__					:							Any													=     SortedLinkedList
       print(merge_lists(SSL(test_data_odd), SSL(test_data_even)))





