



import subprocess
import sys

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

class  snake_case__(_lowerCAmelCase     ):

					"""simple docstring"""






					@require_torch
					def 					snake_case	(				self   :      Tuple	):
									# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
									# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
									# while running an external program

									# python one-liner segments

									# this must be loaded before socket.socket is monkey-patched
									lowercase__	:       Dict						=	"\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        "

									lowercase__	:       Any						=	"\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        "

									lowercase__	:       Tuple						=	"\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
									lowercase__	:       str						=	"hf-internal-testing/tiny-random-bert"
									BertConfig.from_pretrained(SCREAMING_SNAKE_CASE__	)
									BertModel.from_pretrained(SCREAMING_SNAKE_CASE__	)
									BertTokenizer.from_pretrained(SCREAMING_SNAKE_CASE__	)
									pipeline(task="fill-mask" ,  model=SCREAMING_SNAKE_CASE__	)

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

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







					@require_torch
					def 					snake_case	(				self   :      Dict	):
									# python one-liner segments
									# this must be loaded before socket.socket is monkey-patched
									lowercase__	:       int						=	"\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        "

									lowercase__	:       Dict						=	"\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        "

									lowercase__	:       Union[str, Any]						=	"\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
									lowercase__	:       str						=	"hf-internal-testing/tiny-random-bert"
									BertConfig.from_pretrained(SCREAMING_SNAKE_CASE__	)
									BertModel.from_pretrained(SCREAMING_SNAKE_CASE__	)
									BertTokenizer.from_pretrained(SCREAMING_SNAKE_CASE__	)
									pipeline(task="fill-mask" ,  model=SCREAMING_SNAKE_CASE__	)

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

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







					@require_torch
					def 					snake_case	(				self   :      Optional[Any]	):
									# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
									# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
									# while running an external program

									# python one-liner segments

									# this must be loaded before socket.socket is monkey-patched
									lowercase__	:       Optional[Any]						=	"\nfrom transformers import BertConfig, BertModel, BertTokenizer\n        "

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

									lowercase__	:       Tuple						=	"\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
									lowercase__	:       Optional[int]						=	[sys.executable, "-c", "\n".join([load, run]	)]

									# should succeed
									lowercase__	:       Tuple						=	self.get_env()
									lowercase__	:       str						=	subprocess.run(SCREAMING_SNAKE_CASE__ ,  env=SCREAMING_SNAKE_CASE__ ,  check=SCREAMING_SNAKE_CASE__ ,  capture_output=SCREAMING_SNAKE_CASE__	)
									self.assertEqual(result.returncode ,  0 ,  result.stderr	)
									self.assertIn("success" ,  result.stdout.decode()	)

									# next emulate no network
									lowercase__	:       List[str]						=	[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__	:       Union[str, Any]						=	"1"
									lowercase__	:       Optional[int]						=	subprocess.run(SCREAMING_SNAKE_CASE__ ,  env=SCREAMING_SNAKE_CASE__ ,  check=SCREAMING_SNAKE_CASE__ ,  capture_output=SCREAMING_SNAKE_CASE__	)
									self.assertEqual(result.returncode ,  0 ,  result.stderr	)
									self.assertIn("success" ,  result.stdout.decode()	)







					@require_torch
					def 					snake_case	(				self   :      Any	):
									lowercase__	:       Any						=	"\nfrom transformers import pipeline\n        "
									lowercase__	:       str						=	"\nmname = \"hf-internal-testing/tiny-random-bert\"\npipe = pipeline(model=mname)\n        "

									lowercase__	:       str						=	"\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")\nsocket.socket = offline_socket\n        "
									lowercase__	:       List[Any]						=	self.get_env()
									lowercase__	:       Union[str, Any]						=	"1"
									lowercase__	:       Dict						=	[sys.executable, "-c", "\n".join([load, mock, run]	)]
									lowercase__	:       Union[str, Any]						=	subprocess.run(SCREAMING_SNAKE_CASE__ ,  env=SCREAMING_SNAKE_CASE__ ,  check=SCREAMING_SNAKE_CASE__ ,  capture_output=SCREAMING_SNAKE_CASE__	)
									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	):
									lowercase__	:       Dict						=	"\nfrom transformers import AutoModel\n        "
									lowercase__	:       Optional[Any]						=	"\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
									lowercase__	:       Tuple						=	[sys.executable, "-c", "\n".join([load, run]	)]

									# should succeed
									lowercase__	:       List[Any]						=	self.get_env()
									lowercase__	:       Tuple						=	subprocess.run(SCREAMING_SNAKE_CASE__ ,  env=SCREAMING_SNAKE_CASE__ ,  check=SCREAMING_SNAKE_CASE__ ,  capture_output=SCREAMING_SNAKE_CASE__	)
									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__	:       Tuple						=	"1"
									lowercase__	:       List[str]						=	subprocess.run(SCREAMING_SNAKE_CASE__ ,  env=SCREAMING_SNAKE_CASE__ ,  check=SCREAMING_SNAKE_CASE__ ,  capture_output=SCREAMING_SNAKE_CASE__	)
									self.assertEqual(result.returncode ,  0 ,  result.stderr	)
									self.assertIn("success" ,  result.stdout.decode()	)









"""simple docstring"""







from __future__ import annotations

def       _lowerCamelCase				(							UpperCAmelCase_ :       float,	UpperCAmelCase_ :       float,	UpperCAmelCase_ :       float,	)	-> tuple:






	"""simple docstring"""





	if (electron_conc, hole_conc, intrinsic_conc).count(0     ) != 1:
		raise ValueError("You cannot supply more or less than 2 values"     )
	elif electron_conc < 0:
		raise ValueError("Electron concentration cannot be negative in a semiconductor"     )
	elif hole_conc < 0:
		raise ValueError("Hole concentration cannot be negative in a semiconductor"     )
	elif intrinsic_conc < 0:
		raise ValueError(
		    "Intrinsic concentration cannot be negative in a semiconductor"     )
	elif electron_conc == 0:
		return (
		    "electron_conc",
		    intrinsic_conc**2 / hole_conc,
		)
	elif hole_conc == 0:
		return (
		    "hole_conc",
		    intrinsic_conc**2 / electron_conc,
		)
	elif intrinsic_conc == 0:
		return (
		    "intrinsic_conc",
		    (electron_conc * hole_conc) ** 0.5,
		)
	else:
		return (-1, -1)


if __name__ == "__main__":
			import doctest

			doctest.testmod()




