




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


A	     =					logging.getLogger()




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







					'''simple docstring'''




					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase = None		,     _UpperCAmelCase = None		,     _UpperCAmelCase = None		,     _UpperCAmelCase = True		,     ):
									__a	:  Tuple         =					[file for file in os.listdir(__lowerCamelCase       ) if os.path.isfile(os.path.join(__lowerCamelCase		,     __lowerCamelCase       )       )]

									if identifier is not None:
													__a	:  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:
																					__a	:  List[str]         =					[file for file in files if n_ not in file]
													else:
																	__a	:  Optional[int]         =					[file for file in files if n_identifier not in file]

									__a	:  Tuple         =					ignore_files or []
									ignore_files.append('''__init__.py'''       )
									__a	:  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:
																	__a	:  List[str]         =					file.split('''.'''       )[0]
																	try:
																					__a	:  Union[str, Any]         =					getattr(__lowerCamelCase		,     __lowerCamelCase       )
																					__a	:  Any         =					doctest.DocTestSuite(__lowerCamelCase       )
																					__a	:  int         =					unittest.TextTestRunner().run(__lowerCamelCase       )
																					self.assertIs(len(result.failures       )		,     0       )
																	except AttributeError:
																					logger.info(f"""{module_identifier} is not a module."""       )
													else:
																	__a	:  Optional[Any]         =					doctest.testfile(str('''..''' / directory / file       )		,     optionflags=doctest.ELLIPSIS       )
																	self.assertIs(result.failed		,     0       )







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







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







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







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







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






"""simple docstring"""






import os
import string
import sys


A	     =					1 << 8

A	     =					{
    '''tab''': ord('''\t'''),
    '''newline''': ord('''\r'''),
    '''esc''': 27,
    '''up''': 65 + ARROW_KEY_FLAG,
    '''down''': 66 + ARROW_KEY_FLAG,
    '''right''': 67 + ARROW_KEY_FLAG,
    '''left''': 68 + ARROW_KEY_FLAG,
    '''mod_int''': 91,
    '''undefined''': sys.maxsize,
    '''interrupt''': 3,
    '''insert''': 50,
    '''delete''': 51,
    '''pg_up''': 53,
    '''pg_down''': 54,
}

A	     =					KEYMAP['''up''']
A	     =					KEYMAP['''left''']

if sys.platform == "win32":
		A	     =					[]
		A	     =					{
		    B'''\xe0H''': KEYMAP['''up'''] - ARROW_KEY_FLAG,
		    B'''\x00H''': KEYMAP['''up'''] - ARROW_KEY_FLAG,
		    B'''\xe0P''': KEYMAP['''down'''] - ARROW_KEY_FLAG,
		    B'''\x00P''': KEYMAP['''down'''] - ARROW_KEY_FLAG,
		    B'''\xe0M''': KEYMAP['''right'''] - ARROW_KEY_FLAG,
		    B'''\x00M''': KEYMAP['''right'''] - ARROW_KEY_FLAG,
		    B'''\xe0K''': KEYMAP['''left'''] - ARROW_KEY_FLAG,
		    B'''\x00K''': KEYMAP['''left'''] - ARROW_KEY_FLAG,
		}

for i in range(10):
		A	     =					ord(str(i))

def       __A (     )						->						Dict:
				if os.name == "nt":
								import msvcrt

								__a	:  Optional[Any]         =					'''mbcs'''
								# Flush the keyboard buffer
								while msvcrt.kbhit():
												msvcrt.getch()
								if len(a_) == 0:
												# Read the keystroke
												__a	:  Optional[Any]         =					msvcrt.getch()

												# If it is a prefix char, get second part
												if ch in (b"\x00", b"\xe0"):
																__a	:  Optional[Any]         =					ch + msvcrt.getch()
																# Translate actual Win chars to bullet char types
																try:
																				__a	:  Union[str, Any]         =					chr(WIN_KEYMAP[cha])
																				WIN_CH_BUFFER.append(chr(KEYMAP['''mod_int''']))
																				WIN_CH_BUFFER.append(a_)
																				if ord(a_) in (
																				    KEYMAP["insert"] - 1 << 9,
																				    KEYMAP["delete"] - 1 << 9,
																				    KEYMAP["pg_up"] - 1 << 9,
																				    KEYMAP["pg_down"] - 1 << 9,
																				):
																								WIN_CH_BUFFER.append(chr(1_26))
																				__a	:  str         =					chr(KEYMAP['''esc'''])
																except KeyError:
																				__a	:  str         =					cha[1]
												else:
																__a	:  Optional[Any]         =					ch.decode(a_)
								else:
												__a	:  Union[str, Any]         =					WIN_CH_BUFFER.pop(0)
				elif os.name == "posix":
								import termios
								import tty

								__a	:  Any         =					sys.stdin.fileno()
								__a	:  List[str]         =					termios.tcgetattr(a_)
								try:
												tty.setraw(a_)
												__a	:  int         =					sys.stdin.read(1)
								finally:
												termios.tcsetattr(a_				,    termios.TCSADRAIN				,    a_)
				return ch






def       __A (     )						->						str:
				__a	:  Any         =					get_raw_chars()
				if ord(a_) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
								return char

				elif ord(a_) == KEYMAP["esc"]:
								__a	:  str         =					get_raw_chars()
								if ord(a_) == KEYMAP["mod_int"]:
												__a	:  List[str]         =					get_raw_chars()
												if ord(a_) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(a_) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
																return chr(ord(a_) + ARROW_KEY_FLAG)
												else:
																return KEYMAP["undefined"]
								else:
												return get_raw_chars()

				else:
								if char in string.printable:
												return char
								else:
												return KEYMAP["undefined"]