


import unittest

from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


UpperCamelCase								=	get_tests_dir("""fixtures/test_sentencepiece.model""")






@require_sentencepiece
@require_tokenizers
class   _lowerCamelCase (					UpperCamelCase					,							unittest.TestCase			):




       """simple docstring"""
       snake_case      =    XLNetTokenizer
       snake_case      =    XLNetTokenizerFast
       snake_case      =    True
       snake_case      =    True



       def        _snake_case       (      self		)->Optional[Any]:




         '''simple docstring'''





         super().setUp()

         # We have a SentencePiece fixture for testing
         A_      :				List[Any]		     =					XLNetTokenizer(_SCREAMING_SNAKE_CASE				,       keep_accents=_SCREAMING_SNAKE_CASE		)
         tokenizer.sanitize_special_tokens()
         tokenizer.save_pretrained(self.tmpdirname		)



       def        _snake_case       (      self		)->Dict:




         '''simple docstring'''





         A_      :				str		     =					'''<s>'''
         A_      :				List[str]		     =					1

         self.assertEqual(self.get_tokenizer()._convert_token_to_id(_SCREAMING_SNAKE_CASE		)				,       _SCREAMING_SNAKE_CASE		)
         self.assertEqual(self.get_tokenizer()._convert_id_to_token(_SCREAMING_SNAKE_CASE		)				,       _SCREAMING_SNAKE_CASE		)



       def        _snake_case       (      self		)->str:




         '''simple docstring'''





         A_      :				Optional[int]		     =					list(self.get_tokenizer().get_vocab().keys()		)

         self.assertEqual(vocab_keys[0]				,       '''<unk>'''		)
         self.assertEqual(vocab_keys[1]				,       '''<s>'''		)
         self.assertEqual(vocab_keys[-1]				,       '''<eod>'''		)
         self.assertEqual(len(_SCREAMING_SNAKE_CASE		)				,       1006		)



       def        _snake_case       (      self		)->List[str]:




         '''simple docstring'''





         self.assertEqual(self.get_tokenizer().vocab_size				,       1000		)



       def        _snake_case       (      self		)->Any:




         '''simple docstring'''





         A_      :				Tuple		     =					XLNetTokenizer(_SCREAMING_SNAKE_CASE				,       keep_accents=_SCREAMING_SNAKE_CASE		)

         A_      :				List[str]		     =					tokenizer.tokenize('''This is a test'''		)
         self.assertListEqual(_SCREAMING_SNAKE_CASE				,       ['''▁This''', '''▁is''', '''▁a''', '''▁t''', '''est''']		)

         self.assertListEqual(tokenizer.convert_tokens_to_ids(_SCREAMING_SNAKE_CASE		)				,       [285, 46, 10, 170, 382]		)

         A_      :				Dict		     =					tokenizer.tokenize('''I was born in 92000, and this is falsé.'''		)
         self.assertListEqual(
             _SCREAMING_SNAKE_CASE				,       [
                 SPIECE_UNDERLINE + '''I''',
                 SPIECE_UNDERLINE + '''was''',
                 SPIECE_UNDERLINE + '''b''',
                 '''or''',
                 '''n''',
                 SPIECE_UNDERLINE + '''in''',
                 SPIECE_UNDERLINE + '''''',
                 '''9''',
                 '''2''',
                 '''0''',
                 '''0''',
                 '''0''',
                 ''',''',
                 SPIECE_UNDERLINE + '''and''',
                 SPIECE_UNDERLINE + '''this''',
                 SPIECE_UNDERLINE + '''is''',
                 SPIECE_UNDERLINE + '''f''',
                 '''al''',
                 '''s''',
                 '''é''',
                 '''.''',
             ]				,       )
         A_      :				int		     =					tokenizer.convert_tokens_to_ids(_SCREAMING_SNAKE_CASE		)
         self.assertListEqual(_SCREAMING_SNAKE_CASE				,       [8, 21, 84, 55, 24, 19, 7, 0, 602, 347, 347, 347, 3, 12, 66, 46, 72, 80, 6, 0, 4]		)

         A_      :				Optional[int]		     =					tokenizer.convert_ids_to_tokens(_SCREAMING_SNAKE_CASE		)
         self.assertListEqual(
             _SCREAMING_SNAKE_CASE				,       [
                 SPIECE_UNDERLINE + '''I''',
                 SPIECE_UNDERLINE + '''was''',
                 SPIECE_UNDERLINE + '''b''',
                 '''or''',
                 '''n''',
                 SPIECE_UNDERLINE + '''in''',
                 SPIECE_UNDERLINE + '''''',
                 '''<unk>''',
                 '''2''',
                 '''0''',
                 '''0''',
                 '''0''',
                 ''',''',
                 SPIECE_UNDERLINE + '''and''',
                 SPIECE_UNDERLINE + '''this''',
                 SPIECE_UNDERLINE + '''is''',
                 SPIECE_UNDERLINE + '''f''',
                 '''al''',
                 '''s''',
                 '''<unk>''',
                 '''.''',
             ]				,       )



       def        _snake_case       (      self		)->List[Any]:




         '''simple docstring'''





         A_      :				Optional[Any]		     =					XLNetTokenizer(_SCREAMING_SNAKE_CASE				,       do_lower_case=_SCREAMING_SNAKE_CASE		)
         A_      :				int		     =					tokenizer.tokenize('''I was born in 92000, and this is falsé.'''		)
         self.assertListEqual(
             _SCREAMING_SNAKE_CASE				,       [
                 SPIECE_UNDERLINE + '''''',
                 '''i''',
                 SPIECE_UNDERLINE + '''was''',
                 SPIECE_UNDERLINE + '''b''',
                 '''or''',
                 '''n''',
                 SPIECE_UNDERLINE + '''in''',
                 SPIECE_UNDERLINE + '''''',
                 '''9''',
                 '''2''',
                 '''0''',
                 '''0''',
                 '''0''',
                 ''',''',
                 SPIECE_UNDERLINE + '''and''',
                 SPIECE_UNDERLINE + '''this''',
                 SPIECE_UNDERLINE + '''is''',
                 SPIECE_UNDERLINE + '''f''',
                 '''al''',
                 '''se''',
                 '''.''',
             ]				,       )
         self.assertListEqual(tokenizer.tokenize('''H\u00E9llo'''		)				,       ['''▁he''', '''ll''', '''o''']		)



       def        _snake_case       (      self		)->List[Any]:




         '''simple docstring'''





         A_      :				str		     =					XLNetTokenizer(_SCREAMING_SNAKE_CASE				,       do_lower_case=_SCREAMING_SNAKE_CASE		)
         A_      :				List[Any]		     =					tokenizer.tokenize('''I was born in 92000, and this is falsé.'''		)
         self.assertListEqual(
             _SCREAMING_SNAKE_CASE				,       [
                 SPIECE_UNDERLINE + '''I''',
                 SPIECE_UNDERLINE + '''was''',
                 SPIECE_UNDERLINE + '''b''',
                 '''or''',
                 '''n''',
                 SPIECE_UNDERLINE + '''in''',
                 SPIECE_UNDERLINE + '''''',
                 '''9''',
                 '''2''',
                 '''0''',
                 '''0''',
                 '''0''',
                 ''',''',
                 SPIECE_UNDERLINE + '''and''',
                 SPIECE_UNDERLINE + '''this''',
                 SPIECE_UNDERLINE + '''is''',
                 SPIECE_UNDERLINE + '''f''',
                 '''al''',
                 '''se''',
                 '''.''',
             ]				,       )



       @slow
       def        _snake_case       (      self		)->Union[str, Any]:




         '''simple docstring'''





         A_      :				Dict		     =					XLNetTokenizer.from_pretrained('''xlnet-base-cased'''		)

         A_      :				Tuple		     =					tokenizer.encode('''sequence builders'''				,       add_special_tokens=_SCREAMING_SNAKE_CASE		)
         A_      :				Tuple		     =					tokenizer.encode('''multi-sequence build'''				,       add_special_tokens=_SCREAMING_SNAKE_CASE		)

         A_      :				Dict		     =					tokenizer.build_inputs_with_special_tokens(_SCREAMING_SNAKE_CASE		)
         A_      :				Optional[Any]		     =					tokenizer.build_inputs_with_special_tokens(_SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE		)

         assert encoded_sentence == text + [4, 3]
         assert encoded_pair == text + [4] + text_a + [4, 3]







       @slow
       def        _snake_case       (      self		)->Optional[int]:




         '''simple docstring'''





         A_      :				Optional[int]		     =					{'''input_ids''': [[17, 2_1442, 270, 17, 10, 1_4645, 318, 34, 17, 4546, 3145, 787, 13, 7752, 2_2018, 23, 21, 17, 4546, 3145, 787, 13, 3352, 1_4431, 13, 5500, 11, 1176, 580, 13, 1_6819, 4797, 23, 17, 10, 1_7135, 658, 19, 457, 7932, 13, 184, 19, 3154, 1_7135, 6468, 19, 1404, 1_2269, 19, 4229, 5356, 1_6264, 46, 19, 17, 2_0545, 1_0395, 9, 9, 9, 11, 28, 6421, 9531, 2_0729, 17, 10, 353, 1_7022, 11, 21, 6421, 9531, 1_6949, 17, 10, 1_1509, 753, 11, 33, 95, 2421, 7385, 956, 1_4431, 2626, 25, 842, 7385, 4836, 21, 1429, 2272, 9855, 3120, 161, 2_4738, 19, 1_3203, 658, 218, 787, 21, 430, 1_8482, 847, 2637, 9, 4, 3], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]}  # noqa: E501
         # fmt: on

         self.tokenizer_integration_test_util(
             expected_encoding=_SCREAMING_SNAKE_CASE				,       model_name='''xlnet-base-cased'''				,       revision='''c841166438c31ec7ca9a106dee7bb312b73ae511'''				,       )








import copy
import os
from typing import Union

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


UpperCamelCase								=	logging.get_logger(__name__)

UpperCamelCase								=	{
    """google/pix2struct-textcaps-base""": (
        """https://huggingface.co/google/pix2struct-textcaps-base/resolve/main/config.json"""
    ),
}






class   _lowerCamelCase (					UpperCamelCase			):




       """simple docstring"""
       snake_case      =    "pix2struct_text_model"
       snake_case      =    ["past_key_values"]
       snake_case      =    {
           "hidden_size": "hidden_size",
           "num_attention_heads": "num_heads",
           "num_hidden_layers": "num_layers",
       }



       def __init__(      self				,       _SCREAMING_SNAKE_CASE=5_0244				,       _SCREAMING_SNAKE_CASE=768				,       _SCREAMING_SNAKE_CASE=64				,       _SCREAMING_SNAKE_CASE=2048				,       _SCREAMING_SNAKE_CASE=12				,       _SCREAMING_SNAKE_CASE=12				,       _SCREAMING_SNAKE_CASE=32				,       _SCREAMING_SNAKE_CASE=128				,       _SCREAMING_SNAKE_CASE=0.1				,       _SCREAMING_SNAKE_CASE=1e-6				,       _SCREAMING_SNAKE_CASE=1.0				,       _SCREAMING_SNAKE_CASE="gelu_new"				,       _SCREAMING_SNAKE_CASE=0				,       _SCREAMING_SNAKE_CASE=False				,       _SCREAMING_SNAKE_CASE=0				,       _SCREAMING_SNAKE_CASE=1				,       _SCREAMING_SNAKE_CASE=False				,       _SCREAMING_SNAKE_CASE=True				,       **_SCREAMING_SNAKE_CASE				,       )->int:




         '''simple docstring'''





         A_      :				Optional[int]		     =					vocab_size
         A_      :				Any		     =					hidden_size
         A_      :				Optional[Any]		     =					d_kv
         A_      :				int		     =					d_ff
         A_      :				int		     =					num_layers
         A_      :				Dict		     =					num_heads
         A_      :				Any		     =					relative_attention_num_buckets
         A_      :				int		     =					relative_attention_max_distance
         A_      :				Optional[Any]		     =					dropout_rate
         A_      :				Optional[Any]		     =					layer_norm_epsilon
         A_      :				List[Any]		     =					initializer_factor
         A_      :				Optional[int]		     =					use_cache

         A_      :				Optional[Any]		     =					eos_token_id
         A_      :				List[Any]		     =					decoder_start_token_id

         # for backwards compatibility
         A_      :				int		     =					dense_act_fn

         super().__init__(
             pad_token_id=_SCREAMING_SNAKE_CASE				,       eos_token_id=_SCREAMING_SNAKE_CASE				,       decoder_start_token_id=_SCREAMING_SNAKE_CASE				,       tie_word_embeddings=_SCREAMING_SNAKE_CASE				,       is_decoder=_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE				,       )







       @classmethod
       def        _snake_case       (      cls				,       _SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)->"PretrainedConfig":




         '''simple docstring'''





         cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE		)

         A_     ,       A_      :				Union[str, Any]		     =					cls.get_config_dict(_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)

         # get the text config dict if we are loading from Pix2StructConfig
         if config_dict.get('''model_type'''		) == "pix2struct":
           A_      :				Any		     =					config_dict['''text_config''']

         if "model_type" in config_dict and hasattr(cls				,       '''model_type'''		) and config_dict["model_type"] != cls.model_type:
           logger.warning(
               F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
               F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''		)

         return cls.from_dict(_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)






class   _lowerCamelCase (					UpperCamelCase			):




       """simple docstring"""
       snake_case      =    "pix2struct_vision_model"



       def __init__(      self				,       _SCREAMING_SNAKE_CASE=768				,       _SCREAMING_SNAKE_CASE=768				,       _SCREAMING_SNAKE_CASE=2048				,       _SCREAMING_SNAKE_CASE=64				,       _SCREAMING_SNAKE_CASE=12				,       _SCREAMING_SNAKE_CASE=12				,       _SCREAMING_SNAKE_CASE="gelu_new"				,       _SCREAMING_SNAKE_CASE=1e-6				,       _SCREAMING_SNAKE_CASE=0.0				,       _SCREAMING_SNAKE_CASE=0.0				,       _SCREAMING_SNAKE_CASE=1e-10				,       _SCREAMING_SNAKE_CASE=1.0				,       _SCREAMING_SNAKE_CASE=4096				,       _SCREAMING_SNAKE_CASE=32				,       _SCREAMING_SNAKE_CASE=128				,       **_SCREAMING_SNAKE_CASE				,       )->Optional[int]:




         '''simple docstring'''





         super().__init__(**_SCREAMING_SNAKE_CASE		)

         A_      :				Dict		     =					hidden_size
         A_      :				Union[str, Any]		     =					patch_embed_hidden_size
         A_      :				Optional[Any]		     =					d_ff
         A_      :				Optional[Any]		     =					dropout_rate
         A_      :				int		     =					num_hidden_layers
         A_      :				Tuple		     =					num_attention_heads
         A_      :				List[str]		     =					initializer_range
         A_      :				List[str]		     =					initializer_factor
         A_      :				Union[str, Any]		     =					attention_dropout
         A_      :				Union[str, Any]		     =					layer_norm_eps
         A_      :				Dict		     =					dense_act_fn
         A_      :				Union[str, Any]		     =					seq_len
         A_      :				Optional[Any]		     =					relative_attention_num_buckets
         A_      :				Tuple		     =					relative_attention_max_distance
         A_      :				List[Any]		     =					d_kv







       @classmethod
       def        _snake_case       (      cls				,       _SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)->"PretrainedConfig":




         '''simple docstring'''





         cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE		)

         A_     ,       A_      :				str		     =					cls.get_config_dict(_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)

         # get the vision config dict if we are loading from Pix2StructConfig
         if config_dict.get('''model_type'''		) == "pix2struct":
           A_      :				Any		     =					config_dict['''vision_config''']

         if "model_type" in config_dict and hasattr(cls				,       '''model_type'''		) and config_dict["model_type"] != cls.model_type:
           logger.warning(
               F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
               F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''		)

         return cls.from_dict(_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)






class   _lowerCamelCase (					UpperCamelCase			):




       """simple docstring"""
       snake_case      =    "pix2struct"
       snake_case      =    True



       def __init__(      self				,       _SCREAMING_SNAKE_CASE=None				,       _SCREAMING_SNAKE_CASE=None				,       _SCREAMING_SNAKE_CASE=1.0				,       _SCREAMING_SNAKE_CASE=0.0_2				,       _SCREAMING_SNAKE_CASE=False				,       _SCREAMING_SNAKE_CASE=False				,       _SCREAMING_SNAKE_CASE=True				,       **_SCREAMING_SNAKE_CASE				,       )->Any:




         '''simple docstring'''





         super().__init__(tie_word_embeddings=_SCREAMING_SNAKE_CASE				,       is_encoder_decoder=_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)

         if text_config is None:
           A_      :				Dict		     =					{}
           logger.info('''text_config is None. Initializing the Pix2StructTextConfig with default values.'''		)

         if vision_config is None:
           A_      :				List[Any]		     =					{}
           logger.info('''vision_config is None. Initializing the Pix2StructVisionConfig with default values.'''		)

         A_      :				int		     =					PixaStructTextConfig(**_SCREAMING_SNAKE_CASE		)
         A_      :				Dict		     =					PixaStructVisionConfig(**_SCREAMING_SNAKE_CASE		)

         A_      :				Optional[Any]		     =					self.text_config.decoder_start_token_id
         A_      :				Tuple		     =					self.text_config.pad_token_id
         A_      :				Union[str, Any]		     =					self.text_config.eos_token_id

         A_      :				str		     =					initializer_factor
         A_      :				Tuple		     =					initializer_range

         A_      :				List[str]		     =					self.initializer_range
         A_      :				int		     =					self.initializer_range

         A_      :				List[Any]		     =					is_vqa



       @classmethod
       def        _snake_case       (      cls				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)->Union[str, Any]:




         '''simple docstring'''





         return cls(text_config=text_config.to_dict()				,       vision_config=vision_config.to_dict()				,       **_SCREAMING_SNAKE_CASE		)







       def        _snake_case       (      self		)->Dict:




         '''simple docstring'''





         A_      :				List[Any]		     =					copy.deepcopy(self.__dict__		)
         A_      :				Dict		     =					self.text_config.to_dict()
         A_      :				int		     =					self.vision_config.to_dict()
         A_      :				List[str]		     =					self.__class__.model_type
         return output




