
import unittest

from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


lowercase_ 				=			get_tests_dir("""fixtures/spiece.model""")





@require_sentencepiece
@require_tokenizers
class     __UpperCamelCase (							lowerCAmelCase__ ,						unittest.TestCase       ):






     """simple docstring"""







     lowerCAmelCase_							   =			DebertaVaTokenizer
     lowerCAmelCase_							   =			DebertaVaTokenizerFast
     lowerCAmelCase_							   =			True
     lowerCAmelCase_							   =			True



     def  UpperCAmelCase__							(				self							:							Dict ):







       """simple docstring"""




       super().setUp()

       # We have a SentencePiece fixture for testing
       __SCREAMING_SNAKE_CASE      :	str					=		DebertaVaTokenizer(_A     ,						unk_token='''<unk>''' )
       tokenizer.save_pretrained(self.tmpdirname )



     def  UpperCAmelCase__							(				self							:							Union[str, Any]     ,						_A							:							List[Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	str					=		'''this is a test'''
       __SCREAMING_SNAKE_CASE      :	Dict					=		'''this is a test'''
       return input_text, output_text



     def  UpperCAmelCase__							(				self							:							Dict ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		'''<pad>'''
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		0

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



     def  UpperCAmelCase__							(				self							:							Tuple ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		list(self.get_tokenizer().get_vocab().keys() )
       self.assertEqual(vocab_keys[0]     ,						'''<pad>''' )
       self.assertEqual(vocab_keys[1]     ,						'''<unk>''' )
       self.assertEqual(vocab_keys[-1]     ,						'''[PAD]''' )
       self.assertEqual(len(_A )     ,						3_0001 )



     def  UpperCAmelCase__							(				self							:							List[Any] ):







       """simple docstring"""




       self.assertEqual(self.get_tokenizer().vocab_size     ,						3_0000 )



     def  UpperCAmelCase__							(				self							:							Any ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	List[Any]					=		''' \tHeLLo!how  \n Are yoU?  '''
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		['''▁hello''', '''!''', '''how''', '''▁are''', '''▁you''', '''?''']
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	List[str]					=		DebertaVaTokenizer(_A     ,						do_lower_case=_A )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Tuple					=		DebertaVaTokenizerFast(_A     ,						do_lower_case=_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )



     @unittest.skip('''There is an inconsistency between slow and fast tokenizer due to a bug in the fast one.''' )
     def  UpperCAmelCase__							(				self							:							Any ):







       """simple docstring"""




       pass



     @unittest.skip('''There is an inconsistency between slow and fast tokenizer due to a bug in the fast one.''' )
     def  UpperCAmelCase__							(				self							:							Union[str, Any] ):







       """simple docstring"""




       pass



     def  UpperCAmelCase__							(				self							:							List[str] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		'''I was born in 92000, and this is falsé.'''
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		['''▁''', '''<unk>''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', '''▁''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''▁''', '''.''', ]
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	Any					=		DebertaVaTokenizer(_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	Dict					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Tuple					=		DebertaVaTokenizerFast(_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	Tuple					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							Union[str, Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	str					=		'''I was born in 92000, and this is falsé.'''
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		['''▁i''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', '''▁''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''▁''', '''.''', ]
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	List[str]					=		DebertaVaTokenizer(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	int					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )
       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	str					=		DebertaVaTokenizerFast(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )
       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							List[Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Tuple					=		'''I was born in 92000, and this is falsé.'''
       __SCREAMING_SNAKE_CASE      :	List[str]					=		['''▁i''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''.''', ]
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		DebertaVaTokenizer(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		DebertaVaTokenizerFast(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							Optional[int] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Any					=		'''I was born in 92000, and this is falsé.'''
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		['''▁''', '''<unk>''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', '''▁''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''▁''', '''.''', ]
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		DebertaVaTokenizer(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		DebertaVaTokenizerFast(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	Any					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							Any ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		''' \tHeLLo!how  \n Are yoU?  '''
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		['''▁''', '''<unk>''', '''e''', '''<unk>''', '''o''', '''!''', '''how''', '''▁''', '''<unk>''', '''re''', '''▁yo''', '''<unk>''', '''?''']
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	Tuple					=		DebertaVaTokenizer(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	Tuple					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Dict					=		DebertaVaTokenizerFast(_A     ,						do_lower_case=_A     ,						split_by_punct=_A )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )

       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							Union[str, Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		self.get_tokenizer()
       __SCREAMING_SNAKE_CASE      :	Any					=		self.get_rust_tokenizer()

       __SCREAMING_SNAKE_CASE      :	Dict					=		'''I was born in 92000, and this is falsé.'''

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		tokenizer.convert_ids_to_tokens(tokenizer.encode(_A     ,						add_special_tokens=_A ) )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A     ,						add_special_tokens=_A ) )
       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	str					=		tokenizer.encode(_A     ,						add_special_tokens=_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		rust_tokenizer.encode(_A     ,						add_special_tokens=_A )
       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		self.get_rust_tokenizer()
       __SCREAMING_SNAKE_CASE      :	Tuple					=		tokenizer.encode(_A )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		rust_tokenizer.encode(_A )
       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							Any ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		'''This is a test'''
       __SCREAMING_SNAKE_CASE      :	str					=		[13, 1, 4398, 25, 21, 1289]
       __SCREAMING_SNAKE_CASE      :	Any					=		['''▁''', '''T''', '''his''', '''▁is''', '''▁a''', '''▁test''']
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		['''▁''', '''<unk>''', '''his''', '''▁is''', '''▁a''', '''▁test''']

       __SCREAMING_SNAKE_CASE      :	List[str]					=		DebertaVaTokenizer(_A     ,						keep_accents=_A )
       __SCREAMING_SNAKE_CASE      :	Dict					=		DebertaVaTokenizerFast(_A     ,						keep_accents=_A )

       __SCREAMING_SNAKE_CASE      :	int					=		tokenizer.encode(_A     ,						add_special_tokens=_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	Tuple					=		tokenizer.tokenize(_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		tokenizer.convert_ids_to_tokens(_A )
       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	str					=		rust_tokenizer.encode(_A     ,						add_special_tokens=_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	Dict					=		rust_tokenizer.tokenize(_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	Any					=		rust_tokenizer.convert_ids_to_tokens(_A )
       self.assertListEqual(_A     ,						_A )

       # fmt: off
       __SCREAMING_SNAKE_CASE      :	int					=		'''I was born in 92000, and this is falsé.'''
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		[13, 1, 23, 386, 19, 561, 3050, 15, 17, 48, 25, 8256, 18, 1, 9]
       __SCREAMING_SNAKE_CASE      :	str					=		['''▁''', '''I''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''é''', '''.''', ]
       __SCREAMING_SNAKE_CASE      :	Tuple					=		['''▁''', '''<unk>''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''.''', ]
       # fmt: on

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		tokenizer.encode(_A     ,						add_special_tokens=_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		tokenizer.tokenize(_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	str					=		tokenizer.convert_ids_to_tokens(_A )
       self.assertListEqual(_A     ,						_A )

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		rust_tokenizer.encode(_A     ,						add_special_tokens=_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		rust_tokenizer.tokenize(_A )
       self.assertListEqual(_A     ,						_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		rust_tokenizer.convert_ids_to_tokens(_A )
       self.assertListEqual(_A     ,						_A )



     def  UpperCAmelCase__							(				self							:							Optional[Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Dict					=		DebertaVaTokenizer(_A )

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		tokenizer.encode('''sequence builders''' )
       __SCREAMING_SNAKE_CASE      :	Any					=		tokenizer.encode('''multi-sequence build''' )

       __SCREAMING_SNAKE_CASE      :	Tuple					=		tokenizer.build_inputs_with_special_tokens(_A )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		tokenizer.build_inputs_with_special_tokens(_A     ,						_A )

       self.assertEqual([tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]     ,						_A )
       self.assertEqual(
           [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [tokenizer.sep_token_id]     ,						_A     ,						)




     @slow
     def  UpperCAmelCase__							(				self							:							Union[str, Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Any					=		{'''input_ids''': [[1, 3_9867, 36, 1_9390, 486, 27, 3_5052, 8_1436, 18, 6_0685, 1225, 7, 3_5052, 8_1436, 18, 9367, 1_6899, 18, 1_5937, 53, 594, 773, 18, 1_6287, 3_0465, 36, 1_5937, 6, 4_1139, 38, 3_6979, 6_0763, 191, 6, 3_4132, 99, 6, 5_0538, 390, 4_3230, 6, 3_4132, 2779, 2_0850, 14, 699, 1072, 1194, 36, 382, 1_0901, 53, 7, 699, 1072, 2084, 36, 2_0422, 630, 53, 19, 105, 3049, 1896, 1053, 1_6899, 1506, 11, 3_7978, 4243, 7, 1237, 3_1869, 200, 1_6566, 654, 6, 3_5052, 8_1436, 7, 5_5630, 1_3593, 4, 2], [1, 26, 1_5011, 13, 667, 8, 1053, 18, 2_3611, 1237, 7_2356, 1_2820, 34, 10_4134, 1209, 35, 1_3313, 6627, 21, 202, 347, 7, 164, 2399, 11, 46, 4485, 4, 2, 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, 5, 1232, 2864, 1_5785, 1_4951, 105, 5, 8581, 1250, 4, 2, 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]], '''token_type_ids''': [[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, 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, 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]], '''attention_mask''': [[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, 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, 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, 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], [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]]}  # noqa: E501
       # fmt: on

       self.tokenizer_integration_test_util(
           expected_encoding=_A     ,						model_name='''microsoft/deberta-v2-xlarge'''     ,						revision='''ad6e42c1532ddf3a15c39246b63f5559d558b670'''     ,						)





from __future__ import annotations

import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_tf, slow
from transformers.utils import is_tf_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask


if is_tf_available():
				import tensorflow as tf

				from transformers import TFBlipTextModel
				from transformers.models.blip.modeling_tf_blip import TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST






class     __a			:



	def __init__(    self				:     int					,						snake_case_				:     Dict					,						snake_case_				:     List[str]=12					,						snake_case_				:     Optional[int]=7					,						snake_case_				:     Optional[Any]=True					,						snake_case_				:     int=True					,						snake_case_				:     int=True					,						snake_case_				:     Any=99					,						snake_case_				:     List[Any]=32					,						snake_case_				:     List[Any]=32					,						snake_case_				:     Any=2					,						snake_case_				:     Optional[Any]=4					,						snake_case_				:     Optional[Any]=37					,						snake_case_				:     Tuple=0.1					,						snake_case_				:     str=0.1					,						snake_case_				:     Any=5_12					,						snake_case_				:     Optional[Any]=0.0_2					,						snake_case_				:     List[Any]=0					,						snake_case_				:     Union[str, Any]=None					,						)->				List[Any]:
						__lowerCAmelCase						 =parent
						__lowerCAmelCase						 =batch_size
						__lowerCAmelCase						 =seq_length
						__lowerCAmelCase						 =is_training
						__lowerCAmelCase						 =use_input_mask
						__lowerCAmelCase						 =use_labels
						__lowerCAmelCase						 =vocab_size
						__lowerCAmelCase						 =hidden_size
						__lowerCAmelCase						 =projection_dim
						__lowerCAmelCase						 =num_hidden_layers
						__lowerCAmelCase						 =num_attention_heads
						__lowerCAmelCase						 =intermediate_size
						__lowerCAmelCase						 =dropout
						__lowerCAmelCase						 =attention_dropout
						__lowerCAmelCase						 =max_position_embeddings
						__lowerCAmelCase						 =initializer_range
						__lowerCAmelCase						 =scope
						__lowerCAmelCase						 =bos_token_id



	def 		UpperCamelCase				(    self				:     List[Any])->				Optional[int]:
						__lowerCAmelCase						 =ids_tensor([self.batch_size, self.seq_length]					,						self.vocab_size)

						__lowerCAmelCase						 =None
						if self.use_input_mask:
											__lowerCAmelCase						 =random_attention_mask([self.batch_size, self.seq_length])

						if input_mask is not None:
											__lowerCAmelCase						 =input_mask.numpy()
											__lowerCAmelCase ,						__lowerCAmelCase						 =input_mask.shape
											__lowerCAmelCase						 =np.random.randint(1					,						seq_length - 1					,						size=(batch_size,))
											for batch_idx, start_index in enumerate(snake_case_):
																__lowerCAmelCase						 =1
																__lowerCAmelCase						 =0

						__lowerCAmelCase						 =self.get_config()

						return config, input_ids, tf.convert_to_tensor(snake_case_)



	def 		UpperCamelCase				(    self				:     List[str])->				str:
						return BlipTextConfig(
						    vocab_size=self.vocab_size					,						hidden_size=self.hidden_size					,						projection_dim=self.projection_dim					,						num_hidden_layers=self.num_hidden_layers					,						num_attention_heads=self.num_attention_heads					,						intermediate_size=self.intermediate_size					,						dropout=self.dropout					,						attention_dropout=self.attention_dropout					,						max_position_embeddings=self.max_position_embeddings					,						initializer_range=self.initializer_range					,						bos_token_id=self.bos_token_id					,						)



	def 		UpperCamelCase				(    self				:     Union[str, Any]					,						snake_case_				:     Tuple					,						snake_case_				:     List[Any]					,						snake_case_				:     List[Any])->				List[str]:
						__lowerCAmelCase						 =TFBlipTextModel(config=snake_case_)
						__lowerCAmelCase						 =model(snake_case_					,						attention_mask=snake_case_					,						training=snake_case_)
						__lowerCAmelCase						 =model(snake_case_					,						training=snake_case_)
						self.parent.assertEqual(result.last_hidden_state.shape					,						(self.batch_size, self.seq_length, self.hidden_size))
						self.parent.assertEqual(result.pooler_output.shape					,						(self.batch_size, self.hidden_size))



	def 		UpperCamelCase				(    self				:     Dict)->				Tuple:
						__lowerCAmelCase						 =self.prepare_config_and_inputs()
						__lowerCAmelCase ,						__lowerCAmelCase ,						__lowerCAmelCase						 =config_and_inputs
						__lowerCAmelCase						 ={"""input_ids""": input_ids, """attention_mask""": input_mask}
						return config, inputs_dict






@require_tf
class     __a			(  SCREAMING_SNAKE_CASE						,     unittest.TestCase					):
	SCREAMING_SNAKE_CASE  	=							(TFBlipTextModel,) if is_tf_available() else ()
	SCREAMING_SNAKE_CASE  	=							False
	SCREAMING_SNAKE_CASE  	=							False
	SCREAMING_SNAKE_CASE  	=							False



	def 		UpperCamelCase				(    self				:     Optional[Any])->				Any:
						__lowerCAmelCase						 =BlipTextModelTester(self)
						__lowerCAmelCase						 =ConfigTester(self					,						config_class=snake_case_					,						hidden_size=37)



	def 		UpperCamelCase				(    self				:     List[Any])->				List[str]:
						self.config_tester.run_common_tests()



	def 		UpperCamelCase				(    self				:     List[str])->				Dict:
						__lowerCAmelCase						 =self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*snake_case_)



	def 		UpperCamelCase				(    self				:     Optional[Any])->				str:
						pass



	def 		UpperCamelCase				(    self				:     List[str])->				int:
						pass



	@unittest.skip(reason="""Blip does not use inputs_embeds""")
	def 		UpperCamelCase				(    self				:     Optional[Any])->				int:
						pass



	@unittest.skip(reason="""BlipTextModel has no base class and is not available in MODEL_MAPPING""")
	def 		UpperCamelCase				(    self				:     List[Any])->				str:
						pass



	@unittest.skip(reason="""BlipTextModel has no base class and is not available in MODEL_MAPPING""")
	def 		UpperCamelCase				(    self				:     Optional[int])->				Tuple:
						pass



	@slow
	def 		UpperCamelCase				(    self				:     int)->				str:
						for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											__lowerCAmelCase						 =TFBlipTextModel.from_pretrained(snake_case_)
											self.assertIsNotNone(snake_case_)



	def 		UpperCamelCase				(    self				:     str					,						snake_case_				:     List[str]=True)->				int:
						super().test_pt_tf_model_equivalence(allow_missing_keys=snake_case_)




