



"""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    lowercase__     (					SCREAMING_SNAKE_CASE       ,      unittest.TestCase   ):







       '''simple docstring'''


       UpperCamelCase		=  LxmertTokenizer
       UpperCamelCase		=  LxmertTokenizerFast
       UpperCamelCase		=  True
       UpperCamelCase		=  True



       def   lowercase__       (							self    :						Tuple					)				->		Any:


             '''simple docstring'''




             super().setUp()

             UpperCAmelCase_    				=							[
                 "[UNK]",
                 "[CLS]",
                 "[SEP]",
                 "want",
                 "##want",
                 "##ed",
                 "wa",
                 "un",
                 "runn",
                 "##ing",
                 ",",
                 "low",
                 "lowest",
             ]
             UpperCAmelCase_    				=							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   lowercase__       (							self    :						Dict	,       _UpperCAmelCase    :						int					)				->		Union[str, Any]:


             '''simple docstring'''




             UpperCAmelCase_    				=							"UNwant\u00E9d,running"
             UpperCAmelCase_    				=							"unwanted, running"
             return input_text, output_text



       def   lowercase__       (							self    :						Dict					)				->		str:


             '''simple docstring'''




             UpperCAmelCase_    				=							self.tokenizer_class(self.vocab_file					)

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







       def   lowercase__       (							self    :						Any					)				->		Dict:


             '''simple docstring'''




             if not self.test_rust_tokenizer:
                   return

             UpperCAmelCase_    				=							self.get_tokenizer()
             UpperCAmelCase_    				=							self.get_rust_tokenizer()

             UpperCAmelCase_    				=							"I was born in 92000, and this is falsé."

             UpperCAmelCase_    				=							tokenizer.tokenize(_UpperCAmelCase					)
             UpperCAmelCase_    				=							rust_tokenizer.tokenize(_UpperCAmelCase					)
             self.assertListEqual(_UpperCAmelCase	,       _UpperCAmelCase					)

             UpperCAmelCase_    				=							tokenizer.encode(_UpperCAmelCase	,       add_special_tokens=_UpperCAmelCase					)
             UpperCAmelCase_    				=							rust_tokenizer.encode(_UpperCAmelCase	,       add_special_tokens=_UpperCAmelCase					)
             self.assertListEqual(_UpperCAmelCase	,       _UpperCAmelCase					)

             UpperCAmelCase_    				=							self.get_rust_tokenizer()
             UpperCAmelCase_    				=							tokenizer.encode(_UpperCAmelCase					)
             UpperCAmelCase_    				=							rust_tokenizer.encode(_UpperCAmelCase					)
             self.assertListEqual(_UpperCAmelCase	,       _UpperCAmelCase					)









"""simple docstring"""





from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase      =		logging.get_logger(__name__)

lowerCamelCase      =		{
    """YituTech/conv-bert-base""": """https://huggingface.co/YituTech/conv-bert-base/resolve/main/config.json""",
    """YituTech/conv-bert-medium-small""": (
        """https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/config.json"""
    ),
    """YituTech/conv-bert-small""": """https://huggingface.co/YituTech/conv-bert-small/resolve/main/config.json""",
    # See all ConvBERT models at https://huggingface.co/models?filter=convbert
}
class    lowercase__     (					SCREAMING_SNAKE_CASE   ):







       '''simple docstring'''


       UpperCamelCase		=  '''convbert'''



       def __init__(							self    :						Any	,       _UpperCAmelCase    :						Optional[int]=30522	,       _UpperCAmelCase    :						Tuple=768	,       _UpperCAmelCase    :						Optional[int]=12	,       _UpperCAmelCase    :						Dict=12	,       _UpperCAmelCase    :						Any=3072	,       _UpperCAmelCase    :						Dict="gelu"	,       _UpperCAmelCase    :						Optional[int]=0.1	,       _UpperCAmelCase    :						str=0.1	,       _UpperCAmelCase    :						Tuple=512	,       _UpperCAmelCase    :						Optional[Any]=2	,       _UpperCAmelCase    :						Union[str, Any]=0.02	,       _UpperCAmelCase    :						Dict=1e-12	,       _UpperCAmelCase    :						Optional[int]=1	,       _UpperCAmelCase    :						int=0	,       _UpperCAmelCase    :						Optional[Any]=2	,       _UpperCAmelCase    :						List[Any]=768	,       _UpperCAmelCase    :						Optional[int]=2	,       _UpperCAmelCase    :						str=9	,       _UpperCAmelCase    :						List[Any]=1	,       _UpperCAmelCase    :						Optional[Any]=None	,       **_UpperCAmelCase    :						str	,       )				->		List[Any]:


             '''simple docstring'''




             super().__init__(
                 pad_token_id=_UpperCAmelCase	,       bos_token_id=_UpperCAmelCase	,       eos_token_id=_UpperCAmelCase	,       **_UpperCAmelCase	,       )

             UpperCAmelCase_    				=							vocab_size
             UpperCAmelCase_    				=							hidden_size
             UpperCAmelCase_    				=							num_hidden_layers
             UpperCAmelCase_    				=							num_attention_heads
             UpperCAmelCase_    				=							intermediate_size
             UpperCAmelCase_    				=							hidden_act
             UpperCAmelCase_    				=							hidden_dropout_prob
             UpperCAmelCase_    				=							attention_probs_dropout_prob
             UpperCAmelCase_    				=							max_position_embeddings
             UpperCAmelCase_    				=							type_vocab_size
             UpperCAmelCase_    				=							initializer_range
             UpperCAmelCase_    				=							layer_norm_eps
             UpperCAmelCase_    				=							embedding_size
             UpperCAmelCase_    				=							head_ratio
             UpperCAmelCase_    				=							conv_kernel_size
             UpperCAmelCase_    				=							num_groups
             UpperCAmelCase_    				=							classifier_dropout



class    lowercase__     (					SCREAMING_SNAKE_CASE   ):







       '''simple docstring'''


       @property
       def   lowercase__       (							self    :						Dict					)				->		Mapping[str, Mapping[int, str]]:


             '''simple docstring'''




             if self.task == "multiple-choice":
                   UpperCAmelCase_    				=							{0: "batch", 1: "choice", 2: "sequence"}
             else:
                   UpperCAmelCase_    				=							{0: "batch", 1: "sequence"}
             return OrderedDict(
                 [
                     ("input_ids", dynamic_axis),
                     ("attention_mask", dynamic_axis),
                     ("token_type_ids", dynamic_axis),
                 ]					)




