
'''simple docstring'''



import unittest

from transformers import is_vision_available
from transformers.pipelines import pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
						from PIL import Image
else:




						class   UpperCAmelCase_					:






												'''simple docstring'''






												@staticmethod
												def  _lowercase     ( *_lowercase   ,       **_lowercase				):

																		"""simple docstring"""



																		pass




@is_pipeline_test
@require_vision
class   UpperCAmelCase_					(		unittest.TestCase			):






						'''simple docstring'''






						@require_torch
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			pipeline(
												    model="""hf-internal-testing/tiny-random-clip-zero-shot-image-classification"""   ,       )
												_lowerCAmelCase  						=			Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""				)
												_lowerCAmelCase  						=			image_classifier(_lowercase   ,       candidate_labels=["""a""", """b""", """c"""]				)

												# The floating scores are so close, we enter floating error approximation and the order is not guaranteed across
												# python and torch versions.
												self.assertIn(
												    nested_simplify(_lowercase				)   ,       [
												        [{"""score""": 0.333, """label""": """a"""}, {"""score""": 0.333, """label""": """b"""}, {"""score""": 0.333, """label""": """c"""}],
												        [{"""score""": 0.333, """label""": """a"""}, {"""score""": 0.333, """label""": """c"""}, {"""score""": 0.333, """label""": """b"""}],
												    ]   ,       )

												_lowerCAmelCase  						=			image_classifier([image] * 5   ,       candidate_labels=["""A""", """B""", """C"""]   ,       batch_size=2				)
												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												    ]   ,       )




						@require_tf
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			pipeline(
												    model="""hf-internal-testing/tiny-random-clip-zero-shot-image-classification"""   ,       framework="""tf"""				)
												_lowerCAmelCase  						=			Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""				)
												_lowerCAmelCase  						=			image_classifier(_lowercase   ,       candidate_labels=["""a""", """b""", """c"""]				)

												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [{"""score""": 0.333, """label""": """a"""}, {"""score""": 0.333, """label""": """b"""}, {"""score""": 0.333, """label""": """c"""}]   ,       )

												_lowerCAmelCase  						=			image_classifier([image] * 5   ,       candidate_labels=["""A""", """B""", """C"""]   ,       batch_size=2				)
												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												        [
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												            {"""score""": 0.333, """label""": ANY(_lowercase				)},
												        ],
												    ]   ,       )




						@slow
						@require_torch
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			pipeline(
												    task="""zero-shot-image-classification"""   ,       model="""openai/clip-vit-base-patch32"""   ,       )
												# This is an image of 2 cats with remotes and no planes
												_lowerCAmelCase  						=			Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""				)
												_lowerCAmelCase  						=			image_classifier(_lowercase   ,       candidate_labels=["""cat""", """plane""", """remote"""]				)

												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [
												        {"""score""": 0.511, """label""": """remote"""},
												        {"""score""": 0.485, """label""": """cat"""},
												        {"""score""": 0.004, """label""": """plane"""},
												    ]   ,       )

												_lowerCAmelCase  						=			image_classifier([image] * 5   ,       candidate_labels=["""cat""", """plane""", """remote"""]   ,       batch_size=2				)
												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [
												        [
												            {"""score""": 0.511, """label""": """remote"""},
												            {"""score""": 0.485, """label""": """cat"""},
												            {"""score""": 0.004, """label""": """plane"""},
												        ],
												    ]
												    * 5   ,       )




						@slow
						@require_tf
						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			pipeline(
												    task="""zero-shot-image-classification"""   ,       model="""openai/clip-vit-base-patch32"""   ,       framework="""tf"""				)
												# This is an image of 2 cats with remotes and no planes
												_lowerCAmelCase  						=			Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""				)
												_lowerCAmelCase  						=			image_classifier(_lowercase   ,       candidate_labels=["""cat""", """plane""", """remote"""]				)
												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [
												        {"""score""": 0.511, """label""": """remote"""},
												        {"""score""": 0.485, """label""": """cat"""},
												        {"""score""": 0.004, """label""": """plane"""},
												    ]   ,       )

												_lowerCAmelCase  						=			image_classifier([image] * 5   ,       candidate_labels=["""cat""", """plane""", """remote"""]   ,       batch_size=2				)
												self.assertEqual(
												    nested_simplify(_lowercase				)   ,       [
												        [
												            {"""score""": 0.511, """label""": """remote"""},
												            {"""score""": 0.485, """label""": """cat"""},
												            {"""score""": 0.004, """label""": """plane"""},
												        ],
												    ]
												    * 5   ,       )


'''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)
