


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  _a							(    unittest.TestCase):




	def 							UpperCAmelCase__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		Path		, _SCREAMING_SNAKE_CASE						:		Union[str, None] = None		, _SCREAMING_SNAKE_CASE						:		Union[List[str], None] = None		, _SCREAMING_SNAKE_CASE						:		Union[str, List[str], None] = None		, _SCREAMING_SNAKE_CASE						:		bool = True		, )->	Optional[Any]:
			lowerCAmelCase__       :      List[Any]   					= [file for file in os.listdir(__A		) if os.path.isfile(os.path.join(__A		, __A		)		)]

			if identifier is not None:
					lowerCAmelCase__       :      Optional[Any]   					= [file for file in files if identifier in file]

			if n_identifier is not None:
					if isinstance(__A		, __A		):
							for n_ in n_identifier:
									lowerCAmelCase__       :      Dict   					= [file for file in files if n_ not in file]
					else:
							lowerCAmelCase__       :      Union[str, Any]   					= [file for file in files if n_identifier not in file]

			lowerCAmelCase__       :      Any   					= ignore_files or []
			ignore_files.append('''__init__.py'''		)
			lowerCAmelCase__       :      int   					= [file for file in files if file not in ignore_files]

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

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




	def 							UpperCAmelCase__( self						:		Any		)->	List[str]:
			lowerCAmelCase__       :      str   					= Path('''src/transformers'''		)
			lowerCAmelCase__       :      List[Any]   					= '''modeling'''
			lowerCAmelCase__       :      Any   					= [
			    '''modeling_ctrl.py''',
			    '''modeling_tf_ctrl.py''',
			]
			self.analyze_directory(__A		, identifier=__A		, ignore_files=__A		)




	def 							UpperCAmelCase__( self						:		Dict		)->	Optional[Any]:
			lowerCAmelCase__       :      Optional[Any]   					= Path('''src/transformers'''		)
			lowerCAmelCase__       :      Any   					= '''tokenization'''
			self.analyze_directory(__A		, identifier=__A		)




	def 							UpperCAmelCase__( self						:		List[Any]		)->	int:
			lowerCAmelCase__       :      Optional[Any]   					= Path('''src/transformers'''		)
			lowerCAmelCase__       :      str   					= '''configuration'''
			self.analyze_directory(__A		, identifier=__A		)




	def 							UpperCAmelCase__( self						:		Any		)->	Optional[int]:
			lowerCAmelCase__       :      Dict   					= Path('''src/transformers'''		)
			lowerCAmelCase__       :      List[str]   					= ['''configuration''', '''modeling''', '''tokenization''']
			self.analyze_directory(__A		, n_identifier=__A		)




	def 							UpperCAmelCase__( self						:		int		)->	Dict:
			lowerCAmelCase__       :      str   					= Path('''docs/source'''		)
			lowerCAmelCase__       :      Optional[int]   					= ['''favicon.ico''']
			self.analyze_directory(__A		, ignore_files=__A		, only_modules=__A		)






def 					lowerCamelCase_   (	_a	):




		"""simple docstring"""






		if number < 0:
				raise ValueError('''number must not be negative'''	)
		return number & (number - 1) == 0


if __name__ == "__main__":
		import doctest

		doctest.testmod()




