



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


UpperCAmelCase_									=							logging.getLogger()





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





   def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase       ,     _lowerCAmelCase = None       ,     _lowerCAmelCase = None       ,     _lowerCAmelCase = None       ,     _lowerCAmelCase = True       ,     ):
         _lowerCAmelCase 			=  [file for file in os.listdir(_lowerCAmelCase			) if os.path.isfile(os.path.join(_lowerCAmelCase       ,     _lowerCAmelCase			)			)]

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

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





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  Path('''src/transformers'''			)
         _lowerCAmelCase 			=  '''modeling'''
         _lowerCAmelCase 			=  [
             '''modeling_ctrl.py''',
             '''modeling_tf_ctrl.py''',
         ]
         self.analyze_directory(_lowerCAmelCase       ,     identifier=_lowerCAmelCase       ,     ignore_files=_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  Path('''src/transformers'''			)
         _lowerCAmelCase 			=  '''tokenization'''
         self.analyze_directory(_lowerCAmelCase       ,     identifier=_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  Path('''src/transformers'''			)
         _lowerCAmelCase 			=  '''configuration'''
         self.analyze_directory(_lowerCAmelCase       ,     identifier=_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  Path('''src/transformers'''			)
         _lowerCAmelCase 			=  ['''configuration''', '''modeling''', '''tokenization''']
         self.analyze_directory(_lowerCAmelCase       ,     n_identifier=_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  Path('''docs/source'''			)
         _lowerCAmelCase 			=  ['''favicon.ico''']
         self.analyze_directory(_lowerCAmelCase       ,     ignore_files=_lowerCAmelCase       ,     only_modules=_lowerCAmelCase			)




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


UpperCAmelCase_									=							{"processing_layoutxlm": ["LayoutXLMProcessor"]}

try:
    if not is_sentencepiece_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    UpperCAmelCase_									=							["LayoutXLMTokenizer"]

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    UpperCAmelCase_									=							["LayoutXLMTokenizerFast"]

if TYPE_CHECKING:
    from .processing_layoutxlm import LayoutXLMProcessor

    try:
        if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_layoutxlm import LayoutXLMTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_layoutxlm_fast import LayoutXLMTokenizerFast

else:
    import sys

    UpperCAmelCase_									=							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)