



'''simple docstring'''

import numpy

# List of input, output pairs
__lowerCAmelCase									=   (
    ((5, 2, 3), 15),
    ((6, 5, 9), 25),
    ((11, 12, 13), 41),
    ((1, 1, 1), 8),
    ((11, 12, 13), 41),
)
__lowerCAmelCase									=   (((515, 22, 13), 555), ((61, 35, 49), 150))
__lowerCAmelCase									=   [2, 4, 1, 5]
__lowerCAmelCase									=   len(train_data)
__lowerCAmelCase									=   0.009



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_="train"  )			->      Tuple:
		return calculate_hypothesis_value(lowerCAmelCase_						,			lowerCAmelCase_  ) - output(
		    lowerCAmelCase_						,			lowerCAmelCase_  )



def      __lowerCamelCase     (      lowerCAmelCase_  )			->      Dict:
		_a     :      int        =							0
		for i in range(len(lowerCAmelCase_  ) - 1  ):
				hyp_val += data_input_tuple[i] * parameter_vector[i + 1]
		hyp_val += parameter_vector[0]
		return hyp_val



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_  )			->      str:
		if data_set == "train":
				return train_data[example_no][1]
		elif data_set == "test":
				return test_data[example_no][1]
		return None



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_  )			->      List[str]:
		if data_set == "train":
				return _hypothesis_value(train_data[example_no][0]  )
		elif data_set == "test":
				return _hypothesis_value(test_data[example_no][0]  )
		return None



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_=m  )			->      List[str]:
		_a     :      Any        =							0
		for i in range(lowerCAmelCase_  ):
				if index == -1:
						summation_value += _error(lowerCAmelCase_  )
				else:
						summation_value += _error(lowerCAmelCase_  ) * train_data[i][0][index]
		return summation_value



def      __lowerCamelCase     (      lowerCAmelCase_  )			->      Tuple:
		_a     :      Tuple        =							summation_of_cost_derivative(lowerCAmelCase_						,			lowerCAmelCase_  ) / m
		return cost_derivative_value



def      __lowerCamelCase     (      )			->      List[str]:
		global parameter_vector
		# Tune these values to set a tolerance value for predicted output
		_a     :      int        =							0.000_002
		_a     :      str        =							0
		_a     :      Optional[Any]        =							0
		while True:
				j += 1
				_a     :      Tuple        =							[0, 0, 0, 0]
				for i in range(0						,			len(lowerCAmelCase_  )  ):
						_a     :      Union[str, Any]        =							get_cost_derivative(i - 1  )
						_a     :      Any        =							(
						    parameter_vector[i] - LEARNING_RATE * cost_derivative
						)
				if numpy.allclose(
				    lowerCAmelCase_						,			lowerCAmelCase_						,			atol=lowerCAmelCase_						,			rtol=lowerCAmelCase_						,			):
						break
				_a     :      Any        =							temp_parameter_vector
		print(('Number of iterations:', j)  )



def      __lowerCamelCase     (      )			->      str:
		for i in range(len(lowerCAmelCase_  )  ):
				print(('Actual output value:', output(lowerCAmelCase_						,			'test'  ))  )
				print(('Hypothesis output:', calculate_hypothesis_value(lowerCAmelCase_						,			'test'  ))  )


if __name__ == "__main__":
							run_gradient_descent()
							print('''\nTesting gradient descent for a linear hypothesis function.\n''')
							test_gradient_descent()









'''simple docstring'''

import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


__lowerCAmelCase									=   logging.getLogger()

@unittest.skip('Temporarily disable the doc tests.'   )
@require_torch
@require_tf
@slow
class 	__magic_name__						(    unittest.TestCase   ):







							def 							__lowercase			(							self					:       str	,_UpperCAmelCase					:       Path	,_UpperCAmelCase					:       Union[str, None] = None	,_UpperCAmelCase					:       Union[List[str], None] = None	,_UpperCAmelCase					:       Union[str, List[str], None] = None	,_UpperCAmelCase					:       bool = True	,):
									_a     :      Dict        =							[file for file in os.listdir(_UpperCAmelCase		) if os.path.isfile(os.path.join(_UpperCAmelCase	,_UpperCAmelCase		)		)]

									if identifier is not None:
											_a     :      str        =							[file for file in files if identifier in file]

									if n_identifier is not None:
											if isinstance(_UpperCAmelCase	,_UpperCAmelCase		):
													for n_ in n_identifier:
															_a     :      int        =							[file for file in files if n_ not in file]
											else:
													_a     :      Optional[Any]        =							[file for file in files if n_identifier not in file]

									_a     :      Dict        =							ignore_files or []
									ignore_files.append('__init__.py'		)
									_a     :      List[str]        =							[file for file in files if file not in ignore_files]

									for file in files:
											# Open all files
											print('Testing'	,_UpperCAmelCase		)

											if only_modules:
													_a     :      Any        =							file.split('.'		)[0]
													try:
															_a     :      Optional[int]        =							getattr(_UpperCAmelCase	,_UpperCAmelCase		)
															_a     :      Dict        =							doctest.DocTestSuite(_UpperCAmelCase		)
															_a     :      Optional[int]        =							unittest.TextTestRunner().run(_UpperCAmelCase		)
															self.assertIs(len(result.failures		)	,0		)
													except AttributeError:
															logger.info(F"""{module_identifier} is not a module."""		)
											else:
													_a     :      str        =							doctest.testfile(str('..' / directory / file		)	,optionflags=doctest.ELLIPSIS		)
													self.assertIs(result.failed	,0		)







							def 							__lowercase			(							self					:       Union[str, Any]		):
									_a     :      Optional[Any]        =							Path('src/transformers'		)
									_a     :      Optional[Any]        =							'modeling'
									_a     :      Union[str, Any]        =							[
									    'modeling_ctrl.py',
									    'modeling_tf_ctrl.py',
									]
									self.analyze_directory(_UpperCAmelCase	,identifier=_UpperCAmelCase	,ignore_files=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       int		):
									_a     :      str        =							Path('src/transformers'		)
									_a     :      List[str]        =							'tokenization'
									self.analyze_directory(_UpperCAmelCase	,identifier=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       int		):
									_a     :      Any        =							Path('src/transformers'		)
									_a     :      str        =							'configuration'
									self.analyze_directory(_UpperCAmelCase	,identifier=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       Dict		):
									_a     :      Tuple        =							Path('src/transformers'		)
									_a     :      Optional[int]        =							['configuration', 'modeling', 'tokenization']
									self.analyze_directory(_UpperCAmelCase	,n_identifier=_UpperCAmelCase		)







							def 							__lowercase			(							self					:       Optional[Any]		):
									_a     :      Union[str, Any]        =							Path('docs/source'		)
									_a     :      List[str]        =							['favicon.ico']
									self.analyze_directory(_UpperCAmelCase	,ignore_files=_UpperCAmelCase	,only_modules=_UpperCAmelCase		)




