





"""simple docstring"""






import sys

from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

A			      =	'''python tqdm regex requests packaging filelock numpy tokenizers'''.split()
if sys.version_info < (3, 7):
		pkgs_to_check_at_runtime.append('''dataclasses''')
if sys.version_info < (3, 8):
		pkgs_to_check_at_runtime.append('''importlib_metadata''')

for pkg in pkgs_to_check_at_runtime:
		if pkg in deps:
				if pkg == "tokenizers":
						# must be loaded here, or else tqdm check may fail
						from .utils import is_tokenizers_available

						if not is_tokenizers_available():
								continue  # not required, check version only if installed

				require_version_core(deps[pkg])
		else:
				raise ValueError(F'can\'t find {pkg} in {deps.keys()}, check dependency_versions_table.py')

def      __A   (      a_    :Any ,							a_    :int=None)		->		List[str]:
				require_version(deps[pkg] ,							a_)


"""simple docstring"""

import os
import unittest

from transformers import LxmertTokenizer, LxmertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class 			__a					(						__magic_name__       ,	unittest.TestCase       ):





       """simple docstring"""


       __UpperCamelCase					:      Optional[Any]    =						LxmertTokenizer
       __UpperCamelCase					:      Optional[Any]    =						LxmertTokenizerFast
       __UpperCamelCase					:      str    =						True
       __UpperCamelCase					:      Any    =						True






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        super().setUp()

        lowerCAmelCase__   :				Tuple 			=				[
            "[UNK]",
            "[CLS]",
            "[SEP]",
            "want",
            "##want",
            "##ed",
            "wa",
            "un",
            "runn",
            "##ing",
            ",",
            "low",
            "lowest",
        ]
        lowerCAmelCase__   :				Dict 			=				os.path.join(self.tmpdirname			,					VOCAB_FILES_NAMES["vocab_file"]   )
        with open(self.vocab_file			,					"w"			,					encoding="utf-8"   ) as vocab_writer:
         vocab_writer.write("".join([x + "\n" for x in vocab_tokens]   )   )






       def 			SCREAMING_SNAKE_CASE_	(   self			,					snake_case   ):





        """simple docstring"""

        lowerCAmelCase__   :				List[Any] 			=				"UNwant\u00E9d,running"
        lowerCAmelCase__   :				Union[str, Any] 			=				"unwanted, running"
        return input_text, output_text






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				str 			=				self.tokenizer_class(self.vocab_file   )

        lowerCAmelCase__   :				List[Any] 			=				tokenizer.tokenize("UNwant\u00E9d,running"   )
        self.assertListEqual(snake_case			,					["un", "##want", "##ed", ",", "runn", "##ing"]   )
        self.assertListEqual(tokenizer.convert_tokens_to_ids(snake_case   )			,					[7, 4, 5, 10, 8, 9]   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        if not self.test_rust_tokenizer:
         return

        lowerCAmelCase__   :				int 			=				self.get_tokenizer()
        lowerCAmelCase__   :				List[str] 			=				self.get_rust_tokenizer()

        lowerCAmelCase__   :				Optional[Any] 			=				"I was born in 92000, and this is falsé."

        lowerCAmelCase__   :				int 			=				tokenizer.tokenize(snake_case   )
        lowerCAmelCase__   :				int 			=				rust_tokenizer.tokenize(snake_case   )
        self.assertListEqual(snake_case			,					snake_case   )

        lowerCAmelCase__   :				str 			=				tokenizer.encode(snake_case			,					add_special_tokens=snake_case   )
        lowerCAmelCase__   :				List[str] 			=				rust_tokenizer.encode(snake_case			,					add_special_tokens=snake_case   )
        self.assertListEqual(snake_case			,					snake_case   )

        lowerCAmelCase__   :				Tuple 			=				self.get_rust_tokenizer()
        lowerCAmelCase__   :				Tuple 			=				tokenizer.encode(snake_case   )
        lowerCAmelCase__   :				List[Any] 			=				rust_tokenizer.encode(snake_case   )
        self.assertListEqual(snake_case			,					snake_case   )






