






import os
import sys
import unittest


_UpperCAmelCase			:		Optional[int]   				=    os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, "utils"))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
_UpperCAmelCase			:		Union[str, Any]   				=    os.path.join(git_repo_path, "src", "transformers")

_UpperCAmelCase			:		Dict   				=    "\n{0} = None\n"

_UpperCAmelCase			:		Dict   				=    "\nclass {0}(metaclass=DummyObject):\n    _backends = {1}\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, {1})\n"


_UpperCAmelCase			:		List[str]   				=    "\ndef {0}(*args, **kwargs):\n    requires_backends({0}, {1})\n"
class  lowerCAmelCase_       (				unittest.TestCase					):




							def 						__snake_case					(   self     :   str	):
											lowerCAmelCase__      			=						find_backend('''    _import_structure["models.albert"].append("AlbertTokenizerFast")'''	)
											self.assertIsNone(SCREAMING_SNAKE_CASE_	)

											lowerCAmelCase__      			=						find_backend('''    if not is_tokenizers_available():'''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							'''tokenizers'''	)

											lowerCAmelCase__      			=						find_backend('''    if not is_tensorflow_text_available():'''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							'''tensorflow_text'''	)

											lowerCAmelCase__      			=						find_backend('''    if not (is_sentencepiece_available() and is_tokenizers_available()):'''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							'''sentencepiece_and_tokenizers'''	)

											lowerCAmelCase__      			=						find_backend(
											    '''    if not (is_sentencepiece_available() and is_tensorflow_text_available()):'''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							'''sentencepiece_and_tensorflow_text'''	)

											lowerCAmelCase__      			=						find_backend(
											    '''    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):'''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							'''sentencepiece_and_tokenizers_and_vision'''	)




							def 						__snake_case					(   self     :   str	):
											lowerCAmelCase__      			=						read_init()
											# We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
											self.assertIn('''torch''' ,							SCREAMING_SNAKE_CASE_	)
											self.assertIn('''tensorflow_text''' ,							SCREAMING_SNAKE_CASE_	)
											self.assertIn('''sentencepiece_and_tokenizers''' ,							SCREAMING_SNAKE_CASE_	)

											# Likewise, we can't assert on the exact content of a key
											self.assertIn('''BertModel''' ,							objects['''torch''']	)
											self.assertIn('''TFBertModel''' ,							objects['''tf''']	)
											self.assertIn('''FlaxBertModel''' ,							objects['''flax''']	)
											self.assertIn('''BertModel''' ,							objects['''torch''']	)
											self.assertIn('''TFBertTokenizer''' ,							objects['''tensorflow_text''']	)
											self.assertIn('''convert_slow_tokenizer''' ,							objects['''sentencepiece_and_tokenizers''']	)




							def 						__snake_case					(   self     :   Union[str, Any]	):
											lowerCAmelCase__      			=						create_dummy_object('''CONSTANT''' ,							'''\'torch\''''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							'''\nCONSTANT = None\n'''	)

											lowerCAmelCase__      			=						create_dummy_object('''function''' ,							'''\'torch\''''	)
											self.assertEqual(
											    SCREAMING_SNAKE_CASE_ ,							'''\ndef function(*args, **kwargs):\n    requires_backends(function, \'torch\')\n'''	)

											lowerCAmelCase__      			=						'''
class FakeClass(metaclass=DummyObject):
    _backends = \'torch\'

    def __init__(self, *args, **kwargs):
        requires_backends(self, \'torch\')
'''
											lowerCAmelCase__      			=						create_dummy_object('''FakeClass''' ,							'''\'torch\''''	)
											self.assertEqual(SCREAMING_SNAKE_CASE_ ,							SCREAMING_SNAKE_CASE_	)




							def 						__snake_case					(   self     :   Optional[Any]	):
											lowerCAmelCase__      			=						'''# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, ["torch"])


class FakeClass(metaclass=DummyObject):
    _backends = ["torch"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, ["torch"])
'''
											lowerCAmelCase__      			=						create_dummy_files({'''torch''': ['''CONSTANT''', '''function''', '''FakeClass''']}	)
											self.assertEqual(dummy_files['''torch'''] ,							SCREAMING_SNAKE_CASE_	)













from math import isclose, sqrt





def 	lowerCAmelCase_		(lowercase__						:       float     ,					lowercase__						:       float     ,					lowercase__						:       float       )		->    tuple[float, float, float]:


				'''simple docstring'''




				lowerCAmelCase__      			=						point_y / 4 / point_x
				lowerCAmelCase__      			=						2 * normal_gradient / (1 + normal_gradient * normal_gradient)
				lowerCAmelCase__      			=						(1 - normal_gradient * normal_gradient) / (
				    1 + normal_gradient * normal_gradient
				)
				lowerCAmelCase__      			=						(sa - ca * incoming_gradient) / (ca + sa * incoming_gradient)

				# to find the next point, solve the simultaeneous equations:
				# y^2 + 4x^2 = 100
				# y - b = m * (x - a)
				# ==> A x^2 + B x + C = 0
				lowerCAmelCase__      			=						outgoing_gradient**2 + 4
				lowerCAmelCase__      			=						2 * outgoing_gradient * (point_y - outgoing_gradient * point_x)
				lowerCAmelCase__      			=						(point_y - outgoing_gradient * point_x) ** 2 - 1_00

				lowerCAmelCase__      			=						(
				    -linear_term - sqrt(linear_term**2 - 4 * quadratic_term * constant_term       )
				) / (2 * quadratic_term)
				lowerCAmelCase__      			=						(
				    -linear_term + sqrt(linear_term**2 - 4 * quadratic_term * constant_term       )
				) / (2 * quadratic_term)

				# two solutions, one of which is our input point
				lowerCAmelCase__      			=						x_minus if isclose(lowercase__     ,					lowercase__       ) else x_plus
				lowerCAmelCase__      			=						point_y + outgoing_gradient * (next_x - point_x)

				return next_x, next_y, outgoing_gradient





def 	lowerCAmelCase_		(lowercase__						:       float = 1.4     ,					lowercase__						:       float = -9.6       )		->    int:


				'''simple docstring'''




				lowerCAmelCase__      			=						0
				lowerCAmelCase__      			=						first_x_coord
				lowerCAmelCase__      			=						first_y_coord
				lowerCAmelCase__      			=						(10.1 - point_y) / (0.0 - point_x)

				while not (-0.01 <= point_x <= 0.01 and point_y > 0):
								lowerCAmelCase__			,		lowerCAmelCase__			,		lowerCAmelCase__      			=						next_point(lowercase__     ,					lowercase__     ,					lowercase__       )
								num_reflections += 1

				return num_reflections


if __name__ == "__main__":
			print(F'''{solution() = }''')





