



import pickle
import shutil
import tempfile
import unittest

from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


lowerCAmelCase__		:					List[str]							=get_tests_dir('''fixtures/test_sentencepiece.model''')

@require_sentencepiece
@require_tokenizers
class        UpperCAmelCase_  (       UpperCAmelCase__   ,   unittest.TestCase	):

						'''simple docstring'''




						UpperCamelCase__      :			str      =  XLMRobertaTokenizer
						UpperCamelCase__      :			List[Any]      =  XLMRobertaTokenizerFast
						UpperCamelCase__      :			Union[str, Any]      =  True
						UpperCamelCase__      :			Tuple      =  True






						def 	_A     (   self		):







													'''simple docstring'''

													super().setUp()

													# We have a SentencePiece fixture for testing
													__SCREAMING_SNAKE_CASE									= XLMRobertaTokenizer(_SCREAMING_SNAKE_CASE				,							keep_accents=_SCREAMING_SNAKE_CASE		)
													tokenizer.save_pretrained(self.tmpdirname		)






						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= """<pad>"""
													__SCREAMING_SNAKE_CASE									= 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 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= list(self.get_tokenizer().get_vocab().keys()		)

													self.assertEqual(vocab_keys[0]				,							'<s>'		)
													self.assertEqual(vocab_keys[1]				,							'<pad>'		)
													self.assertEqual(vocab_keys[-1]				,							'<mask>'		)
													self.assertEqual(len(_SCREAMING_SNAKE_CASE		)				,							1_002		)






						def 	_A     (   self		):







													'''simple docstring'''

													self.assertEqual(self.get_tokenizer().vocab_size				,							1_002		)






						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= XLMRobertaTokenizer(_SCREAMING_SNAKE_CASE				,							keep_accents=_SCREAMING_SNAKE_CASE		)

													__SCREAMING_SNAKE_CASE									= 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		)				,							[value + tokenizer.fairseq_offset for value in [285, 46, 10, 170, 382]]				,							)

													__SCREAMING_SNAKE_CASE									= 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',
													        'é',
													        '.',
													    ]				,							)
													__SCREAMING_SNAKE_CASE									= tokenizer.convert_tokens_to_ids(_SCREAMING_SNAKE_CASE		)
													self.assertListEqual(
													    _SCREAMING_SNAKE_CASE				,							[
													        value + tokenizer.fairseq_offset
													        for value in [8, 21, 84, 55, 24, 19, 7, 2, 602, 347, 347, 347, 3, 12, 66, 46, 72, 80, 6, 2, 4]
													        #                                       ^ unk: 2 + 1 = 3                  unk: 2 + 1 = 3 ^
													    ]				,							)

													__SCREAMING_SNAKE_CASE									= 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 	_A     (   self		):







													'''simple docstring'''

													if not self.test_slow_tokenizer:
																				# as we don't have a slow version, we can't compare the outputs between slow and fast versions
																				return

													__SCREAMING_SNAKE_CASE									= (self.rust_tokenizer_class, """hf-internal-testing/tiny-xlm-roberta""", {})
													for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																				with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""		):
																											__SCREAMING_SNAKE_CASE									= self.rust_tokenizer_class.from_pretrained(_SCREAMING_SNAKE_CASE				,							**_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= self.tokenizer_class.from_pretrained(_SCREAMING_SNAKE_CASE				,							**_SCREAMING_SNAKE_CASE		)

																											__SCREAMING_SNAKE_CASE									= tempfile.mkdtemp()

																											__SCREAMING_SNAKE_CASE									= tokenizer_r.save_pretrained(_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= tokenizer_p.save_pretrained(_SCREAMING_SNAKE_CASE		)

																											# Checks it save with the same files + the tokenizer.json file for the fast one
																											self.assertTrue(any('tokenizer.json' in f for f in tokenizer_r_files		)		)
																											__SCREAMING_SNAKE_CASE									= tuple(f for f in tokenizer_r_files if 'tokenizer.json' not in f		)
																											self.assertSequenceEqual(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)

																											# Checks everything loads correctly in the same way
																											__SCREAMING_SNAKE_CASE									= tokenizer_r.from_pretrained(_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= tokenizer_p.from_pretrained(_SCREAMING_SNAKE_CASE		)

																											# Check special tokens are set accordingly on Rust and Python
																											for key in tokenizer_pp.special_tokens_map:
																																		self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)		)
																																		# self.assertEqual(getattr(tokenizer_rp, key), getattr(tokenizer_pp, key))
																																		# self.assertEqual(getattr(tokenizer_rp, key + "_id"), getattr(tokenizer_pp, key + "_id"))

																											shutil.rmtree(_SCREAMING_SNAKE_CASE		)

																											# Save tokenizer rust, legacy_format=True
																											__SCREAMING_SNAKE_CASE									= tempfile.mkdtemp()

																											__SCREAMING_SNAKE_CASE									= tokenizer_r.save_pretrained(_SCREAMING_SNAKE_CASE				,							legacy_format=_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= tokenizer_p.save_pretrained(_SCREAMING_SNAKE_CASE		)

																											# Checks it save with the same files
																											self.assertSequenceEqual(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)

																											# Checks everything loads correctly in the same way
																											__SCREAMING_SNAKE_CASE									= tokenizer_r.from_pretrained(_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= tokenizer_p.from_pretrained(_SCREAMING_SNAKE_CASE		)

																											# Check special tokens are set accordingly on Rust and Python
																											for key in tokenizer_pp.special_tokens_map:
																																		self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)		)

																											shutil.rmtree(_SCREAMING_SNAKE_CASE		)

																											# Save tokenizer rust, legacy_format=False
																											__SCREAMING_SNAKE_CASE									= tempfile.mkdtemp()

																											__SCREAMING_SNAKE_CASE									= tokenizer_r.save_pretrained(_SCREAMING_SNAKE_CASE				,							legacy_format=_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= tokenizer_p.save_pretrained(_SCREAMING_SNAKE_CASE		)

																											# Checks it saved the tokenizer.json file
																											self.assertTrue(any('tokenizer.json' in f for f in tokenizer_r_files		)		)

																											# Checks everything loads correctly in the same way
																											__SCREAMING_SNAKE_CASE									= tokenizer_r.from_pretrained(_SCREAMING_SNAKE_CASE		)
																											__SCREAMING_SNAKE_CASE									= tokenizer_p.from_pretrained(_SCREAMING_SNAKE_CASE		)

																											# Check special tokens are set accordingly on Rust and Python
																											for key in tokenizer_pp.special_tokens_map:
																																		self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)		)

																											shutil.rmtree(_SCREAMING_SNAKE_CASE		)






						@cached_property
						def 	_A     (   self		):







													'''simple docstring'''

													return XLMRobertaTokenizer.from_pretrained('xlm-roberta-base'		)






						def 	_A     (   self		):







													'''simple docstring'''

													with tempfile.NamedTemporaryFile() as f:
																				shutil.copyfile(_SCREAMING_SNAKE_CASE				,							f.name		)
																				__SCREAMING_SNAKE_CASE									= XLMRobertaTokenizer(f.name				,							keep_accents=_SCREAMING_SNAKE_CASE		)
																				__SCREAMING_SNAKE_CASE									= pickle.dumps(_SCREAMING_SNAKE_CASE		)
													pickle.loads(_SCREAMING_SNAKE_CASE		)






						def 	_A     (   self		):







													'''simple docstring'''

													if not self.test_rust_tokenizer:
																				return

													__SCREAMING_SNAKE_CASE									= self.get_tokenizer()
													__SCREAMING_SNAKE_CASE									= self.get_rust_tokenizer()

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

													__SCREAMING_SNAKE_CASE									= tokenizer.tokenize(_SCREAMING_SNAKE_CASE		)
													__SCREAMING_SNAKE_CASE									= rust_tokenizer.tokenize(_SCREAMING_SNAKE_CASE		)
													self.assertListEqual(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)

													__SCREAMING_SNAKE_CASE									= tokenizer.encode(_SCREAMING_SNAKE_CASE				,							add_special_tokens=_SCREAMING_SNAKE_CASE		)
													__SCREAMING_SNAKE_CASE									= rust_tokenizer.encode(_SCREAMING_SNAKE_CASE				,							add_special_tokens=_SCREAMING_SNAKE_CASE		)
													self.assertListEqual(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)

													__SCREAMING_SNAKE_CASE									= self.get_rust_tokenizer()
													__SCREAMING_SNAKE_CASE									= tokenizer.encode(_SCREAMING_SNAKE_CASE		)
													__SCREAMING_SNAKE_CASE									= rust_tokenizer.encode(_SCREAMING_SNAKE_CASE		)
													self.assertListEqual(_SCREAMING_SNAKE_CASE				,							_SCREAMING_SNAKE_CASE		)






						@slow
						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= """Hello World!"""
													__SCREAMING_SNAKE_CASE									= [0, 35_378, 6_661, 38, 2]
													# xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.base')  # xlmr.large has same tokenizer
													# xlmr.eval()
													# xlmr.encode(symbols)

													self.assertListEqual(_SCREAMING_SNAKE_CASE				,							self.big_tokenizer.encode(_SCREAMING_SNAKE_CASE		)		)






						@slow
						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= (
													    """This is a very long text with a lot of weird characters, such as: . , ~ ? ( ) \" [ ] ! : - . Also we will"""
													    """ add words that should not exsist and be tokenized to <unk>, such as saoneuhaoesuth"""
													)
													__SCREAMING_SNAKE_CASE									= [
													    0,
													    3_293,
													    83,
													    10,
													    4_552,
													    4_989,
													    7_986,
													    678,
													    10,
													    5_915,
													    111,
													    179_459,
													    124_850,
													    4,
													    6_044,
													    237,
													    12,
													    6,
													    5,
													    6,
													    4,
													    6_780,
													    705,
													    15,
													    1_388,
													    44,
													    378,
													    10_114,
													    711,
													    152,
													    20,
													    6,
													    5,
													    22_376,
													    642,
													    1_221,
													    15_190,
													    34_153,
													    450,
													    5_608,
													    959,
													    1_119,
													    57_702,
													    136,
													    186,
													    47,
													    1_098,
													    29_367,
													    47,
													    # 4426, # What fairseq tokenizes from "<unk>": "_<"
													    # 3678, # What fairseq tokenizes from "<unk>": "unk"
													    # 2740, # What fairseq tokenizes from "<unk>": ">"
													    3,  # What we tokenize from "<unk>": "<unk>"
													    6,  # Residue from the tokenization: an extra sentencepiece underline
													    4,
													    6_044,
													    237,
													    6_284,
													    50_901,
													    528,
													    31,
													    90,
													    34,
													    927,
													    2,
													]
													# xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.base')  # xlmr.large has same tokenizer
													# xlmr.eval()
													# xlmr.encode(symbols)

													self.assertListEqual(_SCREAMING_SNAKE_CASE				,							self.big_tokenizer.encode(_SCREAMING_SNAKE_CASE		)		)






						@slow
						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= {"""input_ids""": [[0, 11_062, 82_772, 7, 15, 82_772, 538, 51_529, 237, 17_198, 1_290, 206, 9, 215_175, 1_314, 136, 17_198, 1_290, 206, 9, 56_359, 42, 122_009, 9, 16_466, 16, 87_344, 4_537, 9, 4_717, 78_381, 6, 159_958, 7, 15, 24_480, 618, 4, 527, 22_693, 5_428, 4, 2_777, 24_480, 9_874, 4, 43_523, 594, 4, 803, 18_392, 33_189, 18, 4, 43_523, 24_447, 12_399, 100, 24_955, 83_658, 9_626, 144_057, 15, 839, 22_335, 16, 136, 24_955, 83_658, 83_479, 15, 39_102, 724, 16, 678, 645, 2_789, 1_328, 4_589, 42, 122_009, 115_774, 23, 805, 1_328, 46_876, 7, 136, 53_894, 1_940, 42_227, 41_159, 17_721, 823, 425, 4, 27_512, 98_722, 206, 136, 5_531, 4_970, 919, 17_336, 5, 2], [0, 20_080, 618, 83, 82_775, 47, 479, 9, 1_517, 73, 53_894, 333, 80_581, 110_117, 18_811, 5_256, 1_295, 51, 152_526, 297, 7_986, 390, 124_416, 538, 35_431, 214, 98, 15_044, 25_737, 136, 7_108, 43_701, 23, 756, 135_355, 7, 5, 2, 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, 581, 63_773, 119_455, 6, 147_797, 88_203, 7, 645, 70, 21, 3_285, 10_269, 5, 2, 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]], """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, 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], [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]]}  # noqa: E501
													# fmt: on

													self.tokenizer_integration_test_util(
													    expected_encoding=_SCREAMING_SNAKE_CASE				,							model_name='xlm-roberta-base'				,							revision='d9d8a8ea5eb94b1c6654ae9249df7793cd2933d3'				,							)











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        UpperCAmelCase_  :

						'''simple docstring'''




						def __init__(   self				,							_A				,							_A=12				,							_A=7				,							_A=True				,							_A=True				,							_A=True				,							_A=99				,							_A=32				,							_A=32				,							_A=2				,							_A=4				,							_A=37				,							_A=0.1				,							_A=0.1				,							_A=512				,							_A=0.0_2				,							_A=0				,							_A=None				,							):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= parent
													__SCREAMING_SNAKE_CASE									= batch_size
													__SCREAMING_SNAKE_CASE									= seq_length
													__SCREAMING_SNAKE_CASE									= is_training
													__SCREAMING_SNAKE_CASE									= use_input_mask
													__SCREAMING_SNAKE_CASE									= use_labels
													__SCREAMING_SNAKE_CASE									= vocab_size
													__SCREAMING_SNAKE_CASE									= hidden_size
													__SCREAMING_SNAKE_CASE									= projection_dim
													__SCREAMING_SNAKE_CASE									= num_hidden_layers
													__SCREAMING_SNAKE_CASE									= num_attention_heads
													__SCREAMING_SNAKE_CASE									= intermediate_size
													__SCREAMING_SNAKE_CASE									= dropout
													__SCREAMING_SNAKE_CASE									= attention_dropout
													__SCREAMING_SNAKE_CASE									= max_position_embeddings
													__SCREAMING_SNAKE_CASE									= initializer_range
													__SCREAMING_SNAKE_CASE									= scope
													__SCREAMING_SNAKE_CASE									= bos_token_id






						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= ids_tensor([self.batch_size, self.seq_length]				,							self.vocab_size		)

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

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

													__SCREAMING_SNAKE_CASE									= self.get_config()

													return config, input_ids, tf.convert_to_tensor(_A		)






						def 	_A     (   self		):







													'''simple docstring'''

													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 	_A     (   self				,							_A				,							_A				,							_A		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= TFBlipTextModel(config=_A		)
													__SCREAMING_SNAKE_CASE									= model(_A				,							attention_mask=_A				,							training=_A		)
													__SCREAMING_SNAKE_CASE									= model(_A				,							training=_A		)
													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 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= self.prepare_config_and_inputs()
													__SCREAMING_SNAKE_CASE							,	__SCREAMING_SNAKE_CASE							,	__SCREAMING_SNAKE_CASE									= config_and_inputs
													__SCREAMING_SNAKE_CASE									= {'input_ids': input_ids, 'attention_mask': input_mask}
													return config, inputs_dict







@require_tf
class        UpperCAmelCase_  (       UpperCamelCase_   ,   unittest.TestCase	):

						'''simple docstring'''




						UpperCamelCase__      :			str      =  (TFBlipTextModel,) if is_tf_available() else ()
						UpperCamelCase__      :			int      =  False
						UpperCamelCase__      :			Optional[Any]      =  False
						UpperCamelCase__      :			Tuple      =  False






						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= BlipTextModelTester(self		)
													__SCREAMING_SNAKE_CASE									= ConfigTester(self				,							config_class=_A				,							hidden_size=37		)






						def 	_A     (   self		):







													'''simple docstring'''

													self.config_tester.run_common_tests()






						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*_A		)






						def 	_A     (   self		):







													'''simple docstring'''

													pass






						def 	_A     (   self		):







													'''simple docstring'''

													pass






						@unittest.skip(reason='Blip does not use inputs_embeds'		)
						def 	_A     (   self		):







													'''simple docstring'''

													pass






						@unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'		)
						def 	_A     (   self		):







													'''simple docstring'''

													pass






						@unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'		)
						def 	_A     (   self		):







													'''simple docstring'''

													pass






						@slow
						def 	_A     (   self		):







													'''simple docstring'''

													for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																				__SCREAMING_SNAKE_CASE									= TFBlipTextModel.from_pretrained(_A		)
																				self.assertIsNotNone(_A		)






						def 	_A     (   self				,							_A=True		):







													'''simple docstring'''

													super().test_pt_tf_model_equivalence(allow_missing_keys=_A		)






