



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


__snake_case    :		Union[str, Any]  =logging.getLogger()



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




		'''simple docstring'''



		def 		lowerCAmelCase__				(self		,__lowerCamelCase		,__lowerCamelCase = None		,__lowerCamelCase = None		,__lowerCamelCase = None		,__lowerCamelCase = True		,)					->      Any:

						"""simple docstring"""






						lowerCAmelCase__					:    Tuple												=					[file for file in os.listdir(__lowerCamelCase			) if os.path.isfile(os.path.join(__lowerCamelCase		,__lowerCamelCase			)			)]

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

						if n_identifier is not None:
										if isinstance(__lowerCamelCase		,__lowerCamelCase			):
														for n_ in n_identifier:
																		lowerCAmelCase__					:    List[str]												=					[file for file in files if n_ not in file]
										else:
														lowerCAmelCase__					:    Optional[int]												=					[file for file in files if n_identifier not in file]

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

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

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



		def 		lowerCAmelCase__				(self			)					->      str:

						"""simple docstring"""






						lowerCAmelCase__					:    Union[str, Any]												=					Path('''src/transformers'''			)
						lowerCAmelCase__					:    Optional[int]												=					'''modeling'''
						lowerCAmelCase__					:    int												=					[
						    '''modeling_ctrl.py''',
						    '''modeling_tf_ctrl.py''',
						]
						self.analyze_directory(__lowerCamelCase		,identifier=__lowerCamelCase		,ignore_files=__lowerCamelCase			)



		def 		lowerCAmelCase__				(self			)					->      int:

						"""simple docstring"""






						lowerCAmelCase__					:    Optional[Any]												=					Path('''src/transformers'''			)
						lowerCAmelCase__					:    str												=					'''tokenization'''
						self.analyze_directory(__lowerCamelCase		,identifier=__lowerCamelCase			)



		def 		lowerCAmelCase__				(self			)					->      int:

						"""simple docstring"""






						lowerCAmelCase__					:    Union[str, Any]												=					Path('''src/transformers'''			)
						lowerCAmelCase__					:    Optional[Any]												=					'''configuration'''
						self.analyze_directory(__lowerCamelCase		,identifier=__lowerCamelCase			)



		def 		lowerCAmelCase__				(self			)					->      int:

						"""simple docstring"""






						lowerCAmelCase__					:    Optional[Any]												=					Path('''src/transformers'''			)
						lowerCAmelCase__					:    Union[str, Any]												=					['''configuration''', '''modeling''', '''tokenization''']
						self.analyze_directory(__lowerCamelCase		,n_identifier=__lowerCamelCase			)



		def 		lowerCAmelCase__				(self			)					->      int:

						"""simple docstring"""






						lowerCAmelCase__					:    List[str]												=					Path('''docs/source'''			)
						lowerCAmelCase__					:    Tuple												=					['''favicon.ico''']
						self.analyze_directory(__lowerCamelCase		,ignore_files=__lowerCamelCase		,only_modules=__lowerCamelCase			)






__snake_case    :		Any  ='\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n'

__snake_case    :		Tuple  =[{'type': 'code', 'content': INSTALL_CONTENT}]
__snake_case    :		Tuple  ={
    '{processor_class}': 'FakeProcessorClass',
    '{model_class}': 'FakeModelClass',
    '{object_class}': 'FakeObjectClass',
}

