
'''simple docstring'''



import subprocess
import sys

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




class   UpperCAmelCase_					(		_SCREAMING_SNAKE_CASE			):






						'''simple docstring'''






						@require_torch
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			"""
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

												_lowerCAmelCase  						=			"""
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\")
        """

												_lowerCAmelCase  						=			"""
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
												_lowerCAmelCase  						=			"""hf-internal-testing/tiny-random-bert"""
												BertConfig.from_pretrained(_lowercase				)
												BertModel.from_pretrained(_lowercase				)
												BertTokenizer.from_pretrained(_lowercase				)
												pipeline(task="""fill-mask"""   ,       model=_lowercase				)

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

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




						@require_torch
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			"""
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

												_lowerCAmelCase  						=			"""
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\")
        """

												_lowerCAmelCase  						=			"""
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
												_lowerCAmelCase  						=			"""hf-internal-testing/tiny-random-bert"""
												BertConfig.from_pretrained(_lowercase				)
												BertModel.from_pretrained(_lowercase				)
												BertTokenizer.from_pretrained(_lowercase				)
												pipeline(task="""fill-mask"""   ,       model=_lowercase				)

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

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




						@require_torch
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			"""
from transformers import BertConfig, BertModel, BertTokenizer
        """

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

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

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

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




						@require_torch
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			"""
from transformers import pipeline
        """
												_lowerCAmelCase  						=			"""
mname = \"hf-internal-testing/tiny-random-bert\"
pipe = pipeline(model=mname)
        """

												_lowerCAmelCase  						=			"""
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")
socket.socket = offline_socket
        """
												_lowerCAmelCase  						=			self.get_env()
												_lowerCAmelCase  						=			"""1"""
												_lowerCAmelCase  						=			[sys.executable, """-c""", """\n""".join([load, mock, run]				)]
												_lowerCAmelCase  						=			subprocess.run(_lowercase   ,       env=_lowercase   ,       check=_lowercase   ,       capture_output=_lowercase				)
												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				):

												"""simple docstring"""



												_lowerCAmelCase  						=			"""
from transformers import AutoModel
        """
												_lowerCAmelCase  						=			"""
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
												_lowerCAmelCase  						=			[sys.executable, """-c""", """\n""".join([load, run]				)]

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


'''simple docstring'''



def A				(__lowerCamelCase				:list[int]			,     __lowerCamelCase				:list[int]		):

						# Check if the input is valid
						if not len(__lowerCamelCase		) == len(__lowerCamelCase		) == 3:
												raise ValueError("""Please enter a valid equation."""		)
						if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0:
												raise ValueError("""Both a & b of two equations can't be zero."""		)

						# Extract the coefficients
						_lowerCAmelCase						,   _lowerCAmelCase						,   _lowerCAmelCase  						=			equationa
						_lowerCAmelCase						,   _lowerCAmelCase						,   _lowerCAmelCase  						=			equationa

						# Calculate the determinants of the matrices
						_lowerCAmelCase  						=			aa * ba - aa * ba
						_lowerCAmelCase  						=			ca * ba - ca * ba
						_lowerCAmelCase  						=			aa * ca - aa * ca

						# Check if the system of linear equations has a solution (using Cramer's rule)
						if determinant == 0:
												if determinant_x == determinant_y == 0:
																		raise ValueError("""Infinite solutions. (Consistent system)"""		)
												else:
																		raise ValueError("""No solution. (Inconsistent system)"""		)
						else:
												if determinant_x == determinant_y == 0:
																		# Trivial solution (Inconsistent system)
																		return (0.0, 0.0)
												else:
																		_lowerCAmelCase  						=			determinant_x / determinant
																		_lowerCAmelCase  						=			determinant_y / determinant
																		# Non-Trivial Solution (Consistent system)
																		return (x, y)
