





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


_SCREAMING_SNAKE_CASE					=    logging.getLogger()






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







	'''simple docstring'''

	def 						_UpperCAmelCase     (self     ,_lowerCamelCase     ,_lowerCamelCase = None     ,_lowerCamelCase = None     ,_lowerCamelCase = None     ,_lowerCamelCase = True     ,)							->							Optional[int]:







				'''simple docstring'''





				__lowercase										=							[file for file in os.listdir(_lowerCamelCase ) if os.path.isfile(os.path.join(_lowerCamelCase     ,_lowerCamelCase ) )]

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

				if n_identifier is not None:
							if isinstance(_lowerCamelCase     ,_lowerCamelCase ):
										for n_ in n_identifier:
													__lowercase										=							[file for file in files if n_ not in file]
							else:
										__lowercase										=							[file for file in files if n_identifier not in file]

				__lowercase										=							ignore_files or []
				ignore_files.append('''__init__.py''' )
				__lowercase										=							[file for file in files if file not in ignore_files]

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

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


	def 						_UpperCAmelCase     (self )							->							str:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							'''modeling'''
				__lowercase										=							[
				    '''modeling_ctrl.py''',
				    '''modeling_tf_ctrl.py''',
				]
				self.analyze_directory(_lowerCamelCase     ,identifier=_lowerCamelCase     ,ignore_files=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							Any:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							'''tokenization'''
				self.analyze_directory(_lowerCamelCase     ,identifier=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							int:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							'''configuration'''
				self.analyze_directory(_lowerCamelCase     ,identifier=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							List[Any]:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							['''configuration''', '''modeling''', '''tokenization''']
				self.analyze_directory(_lowerCamelCase     ,n_identifier=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							Optional[int]:







				'''simple docstring'''





				__lowercase										=							Path('''docs/source''' )
				__lowercase										=							['''favicon.ico''']
				self.analyze_directory(_lowerCamelCase     ,ignore_files=_lowerCamelCase     ,only_modules=_lowerCamelCase )












'''simple docstring'''



from __future__ import annotations

import time
from collections.abc import Sequence
from random import randint

from matplotlib import pyplot as plt




def    _lowerCAmelCase						(				lowerCamelCase_			:  Sequence[float]		,       lowerCamelCase_			:  int		,       lowerCamelCase_			:  int				):
			if not arr:
						return None, None, 0
			if low == high:
						return low, high, arr[low]

			__lowercase										=							(low + high) // 2
			__lowercase						,		__lowercase						,		__lowercase										=							max_subarray(lowerCamelCase_		,       lowerCamelCase_		,       lowerCamelCase_				)
			__lowercase						,		__lowercase						,		__lowercase										=							max_subarray(lowerCamelCase_		,       mid + 1		,       lowerCamelCase_				)
			__lowercase						,		__lowercase						,		__lowercase										=							max_cross_sum(lowerCamelCase_		,       lowerCamelCase_		,       lowerCamelCase_		,       lowerCamelCase_				)
			if left_sum >= right_sum and left_sum >= cross_sum:
						return left_low, left_high, left_sum
			elif right_sum >= left_sum and right_sum >= cross_sum:
						return right_low, right_high, right_sum
			return cross_left, cross_right, cross_sum




def    _lowerCAmelCase						(				lowerCamelCase_			:  Sequence[float]		,       lowerCamelCase_			:  int		,       lowerCamelCase_			:  int		,       lowerCamelCase_			:  int				):
			__lowercase						,		__lowercase										=							float('''-inf'''				), -1
			__lowercase						,		__lowercase										=							float('''-inf'''				), -1

			__lowercase										=							0
			for i in range(lowerCamelCase_		,       low - 1		,       -1				):
						summ += arr[i]
						if summ > left_sum:
									__lowercase										=							summ
									__lowercase										=							i

			__lowercase										=							0
			for i in range(mid + 1		,       high + 1				):
						summ += arr[i]
						if summ > right_sum:
									__lowercase										=							summ
									__lowercase										=							i

			return max_left, max_right, (left_sum + right_sum)




def    _lowerCAmelCase						(				lowerCamelCase_			:  int				):
			__lowercase										=							[randint(1		,       lowerCamelCase_				) for _ in range(lowerCamelCase_				)]
			__lowercase										=							time.time()
			max_subarray(lowerCamelCase_		,       0		,       input_size - 1				)
			__lowercase										=							time.time()
			return end - start




def    _lowerCAmelCase						(				):
			__lowercase										=							[1_0, 1_0_0, 1_0_0_0, 1_0_0_0_0, 5_0_0_0_0, 1_0_0_0_0_0, 2_0_0_0_0_0, 3_0_0_0_0_0, 4_0_0_0_0_0, 5_0_0_0_0_0]
			__lowercase										=							[time_max_subarray(lowerCamelCase_				) for input_size in input_sizes]
			print('''No of Inputs\t\tTime Taken'''				)
			for input_size, runtime in zip(lowerCamelCase_		,       lowerCamelCase_				):
						print(lowerCamelCase_		,       '''\t\t'''		,       lowerCamelCase_				)
			plt.plot(lowerCamelCase_		,       lowerCamelCase_				)
			plt.xlabel('''Number of Inputs'''				)
			plt.ylabel('''Time taken in seconds'''				)
			plt.show()


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

	testmod()





