'''simple docstring'''

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a: List[Any]          =   logging.get_logger(__name__)

__a: Tuple          =   {
    """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""",
}



class 			UpperCAmelCase  (						a__					):





       '''simple docstring'''



       SCREAMING_SNAKE_CASE							=    "lxmert"
       SCREAMING_SNAKE_CASE							=    {}

       def __init__(						self	,   __lowerCAmelCase=30522	,   __lowerCAmelCase=768	,   __lowerCAmelCase=12	,   __lowerCAmelCase=9500	,   __lowerCAmelCase=1600	,   __lowerCAmelCase=400	,   __lowerCAmelCase=3072	,   __lowerCAmelCase="gelu"	,   __lowerCAmelCase=0.1	,   __lowerCAmelCase=0.1	,   __lowerCAmelCase=512	,   __lowerCAmelCase=2	,   __lowerCAmelCase=0.0_2	,   __lowerCAmelCase=1E-12	,   __lowerCAmelCase=9	,   __lowerCAmelCase=5	,   __lowerCAmelCase=5	,   __lowerCAmelCase=2048	,   __lowerCAmelCase=4	,   __lowerCAmelCase=6.6_7	,   __lowerCAmelCase=True	,   __lowerCAmelCase=True	,   __lowerCAmelCase=True	,   __lowerCAmelCase=True	,   __lowerCAmelCase=True	,   __lowerCAmelCase=True	,   __lowerCAmelCase=True	,   **__lowerCAmelCase	,   )  ->  int:
        lowercase__				:    List[Any]  =					vocab_size
        lowercase__				:    List[Any]  =					hidden_size
        lowercase__				:    Optional[int]  =					num_attention_heads
        lowercase__				:    List[Any]  =					hidden_act
        lowercase__				:    str  =					intermediate_size
        lowercase__				:    Union[str, Any]  =					hidden_dropout_prob
        lowercase__				:    Dict  =					attention_probs_dropout_prob
        lowercase__				:    List[Any]  =					max_position_embeddings
        lowercase__				:    List[str]  =					type_vocab_size
        lowercase__				:    Dict  =					initializer_range
        lowercase__				:    Union[str, Any]  =					layer_norm_eps
        lowercase__				:    Dict  =					num_qa_labels
        lowercase__				:    List[Any]  =					num_object_labels
        lowercase__				:    int  =					num_attr_labels
        lowercase__				:    int  =					l_layers
        lowercase__				:    Tuple  =					x_layers
        lowercase__				:    Tuple  =					r_layers
        lowercase__				:    Tuple  =					visual_feat_dim
        lowercase__				:    Optional[Any]  =					visual_pos_dim
        lowercase__				:    Tuple  =					visual_loss_normalizer
        lowercase__				:    List[Any]  =					task_matched
        lowercase__				:    Tuple  =					task_mask_lm
        lowercase__				:    Dict  =					task_obj_predict
        lowercase__				:    Optional[int]  =					task_qa
        lowercase__				:    List[Any]  =					visual_obj_loss
        lowercase__				:    str  =					visual_attr_loss
        lowercase__				:    List[Any]  =					visual_feat_loss
        lowercase__				:    str  =					{'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
        super().__init__(**__lowerCAmelCase )


'''simple docstring'''

import json
import os
import unittest

from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer

from ...test_tokenization_common import TokenizerTesterMixin



class 			UpperCAmelCase  (						a__    ,						unittest.TestCase					):





       '''simple docstring'''



       SCREAMING_SNAKE_CASE							=    CTRLTokenizer
       SCREAMING_SNAKE_CASE							=    False
       SCREAMING_SNAKE_CASE							=    False

       def _lowerCAmelCase(						self )  ->  Dict:
        super().setUp()

        # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
        lowercase__				:    Optional[Any]  =					['''adapt''', '''re@@''', '''a@@''', '''apt''', '''c@@''', '''t''', '''<unk>''']
        lowercase__				:    str  =					dict(zip(__lowerCAmelCase	,   range(len(__lowerCAmelCase ) ) ) )
        lowercase__				:    Tuple  =					['''#version: 0.2''', '''a p''', '''ap t</w>''', '''r e''', '''a d''', '''ad apt</w>''', '''''']
        lowercase__				:    Optional[Any]  =					{'''unk_token''': '''<unk>'''}

        lowercase__				:    Dict  =					os.path.join(self.tmpdirname	,   VOCAB_FILES_NAMES['''vocab_file'''] )
        lowercase__				:    Dict  =					os.path.join(self.tmpdirname	,   VOCAB_FILES_NAMES['''merges_file'''] )
        with open(self.vocab_file	,   '''w'''	,   encoding='''utf-8''' ) as fp:
         fp.write(json.dumps(__lowerCAmelCase ) + '''\n''' )
        with open(self.merges_file	,   '''w'''	,   encoding='''utf-8''' ) as fp:
         fp.write('''\n'''.join(__lowerCAmelCase ) )

       def _lowerCAmelCase(						self	,   **__lowerCAmelCase )  ->  List[str]:
        kwargs.update(self.special_tokens_map )
        return CTRLTokenizer.from_pretrained(self.tmpdirname	,   **__lowerCAmelCase )

       def _lowerCAmelCase(						self	,   __lowerCAmelCase )  ->  List[str]:
        lowercase__				:    List[str]  =					'''adapt react readapt apt'''
        lowercase__				:    Union[str, Any]  =					'''adapt react readapt apt'''
        return input_text, output_text


       def _lowerCAmelCase(						self )  ->  Optional[Any]:
        lowercase__				:    Union[str, Any]  =					CTRLTokenizer(self.vocab_file	,   self.merges_file	,   **self.special_tokens_map )
        lowercase__				:    Optional[Any]  =					'''adapt react readapt apt'''
        lowercase__				:    Dict  =					'''adapt re@@ a@@ c@@ t re@@ adapt apt'''.split()
        lowercase__				:    Union[str, Any]  =					tokenizer.tokenize(__lowerCAmelCase )
        self.assertListEqual(__lowerCAmelCase	,   __lowerCAmelCase )

        lowercase__				:    int  =					tokens + [tokenizer.unk_token]

        lowercase__				:    List[str]  =					[0, 1, 2, 4, 5, 1, 0, 3, 6]
        self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowerCAmelCase )	,   __lowerCAmelCase )

