



import glob
import os

from get_test_info import get_tester_classes


if __name__ == "__main__":
		__magic_name__       =     []

		__magic_name__       =     os.path.join('''tests''', '''models''', '''**''', '''test_modeling_*.py''')
		__magic_name__       =     glob.glob(pattern)
		# TODO: deal with TF/Flax too
		__magic_name__       =     [
		    x for x in test_files if not (x.startswith('''test_modeling_tf_''') or x.startswith('''test_modeling_flax_'''))
		]

		for test_file in test_files:
				__magic_name__       =     get_tester_classes(test_file)
				for tester_class in tester_classes:
						# A few tester classes don't have `parent` parameter in `__init__`.
						# TODO: deal this better
						try:
								__magic_name__       =     tester_class(parent=None)
						except Exception:
								continue
						if hasattr(tester, '''get_config'''):
								__magic_name__       =     tester.get_config()
								for k, v in config.to_dict().items():
										if isinstance(v, int):
												__magic_name__       =     None
												if k in ["vocab_size"]:
														__magic_name__       =     100
												elif k in ["max_position_embeddings"]:
														__magic_name__       =     128
												elif k in ["hidden_size", "d_model"]:
														__magic_name__       =     40
												elif k == ["num_layers", "num_hidden_layers", "num_encoder_layers", "num_decoder_layers"]:
														__magic_name__       =     5
												if target is not None and v > target:
														failures.append(
														    F"""{tester_class.__name__} will produce a `config` of type `{config.__class__.__name__}`"""
														    F""" with config[\"{k}\"] = {v} which is too large for testing! Set its value to be smaller"""
														    F""" than {target}."""
														)

		if len(failures) > 0:
				raise Exception(F"""There were {len(failures)} failures:\n""" + '''\n'''.join(failures))











from __future__ import annotations





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					assert (
					    c % greatest_common_divisor(_UpperCAmelCase       ,			_UpperCAmelCase				) == 0
					)  # greatest_common_divisor(a,b) function implemented below
					((lowercase)   ,      (lowercase)   ,      (lowercase))						   =       extended_gcd(_UpperCAmelCase       ,			_UpperCAmelCase				)  # extended_gcd(a,b) function implemented below
					lowercase						   =       c / d
					return (r * x, r * y)





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase = 2				):
					"""simple docstring"""






					((lowercase)   ,      (lowercase))						   =       diophantine(_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				)  # Initial value
					lowercase						   =       greatest_common_divisor(_UpperCAmelCase       ,			_UpperCAmelCase				)
					lowercase						   =       a // d
					lowercase						   =       b // d

					for i in range(_UpperCAmelCase				):
										lowercase						   =       xa + i * q
										lowercase						   =       ya - i * p
										print(_UpperCAmelCase       ,			_UpperCAmelCase				)





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					if a < b:
										lowercase   ,      lowercase						   =       b, a

					while a % b != 0:
										lowercase   ,      lowercase						   =       b, a % b

					return b





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					assert a >= 0 and b >= 0

					if b == 0:
										lowercase   ,      lowercase   ,      lowercase						   =       a, 1, 0
					else:
										((lowercase)   ,      (lowercase)   ,      (lowercase))						   =       extended_gcd(_UpperCAmelCase       ,			a % b				)
										lowercase						   =       q
										lowercase						   =       p - q * (a // b)

					assert a % d == 0 and b % d == 0
					assert d == a * x + b * y

					return (d, x, y)


if __name__ == "__main__":
		from doctest import testmod

		testmod(name='''diophantine''', verbose=True)
		testmod(name='''diophantine_all_soln''', verbose=True)
		testmod(name='''extended_gcd''', verbose=True)
		testmod(name='''greatest_common_divisor''', verbose=True)






