code: 
  
  
  '''simple docstring'''
  
  import unittest
  
  import numpy as np
  
  from transformers import BlipTextConfig
  from transformers.testing_utils import require_torch, slow, torch_device
  from transformers.utils import is_torch_available
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
  
  
  if is_torch_available():
         import torch
  
         from transformers import BlipTextModel
         from transformers.models.blip.modeling_blip import BLIP_PRETRAINED_MODEL_ARCHIVE_LIST
  
  
  
  
  
  
  
  class  UpperCAmelCase :
  
   def __init__( self :	Optional[Any],					a_ :	List[Any],					a_ :	Optional[int]=12,					a_ :	List[Any]=7,					a_ :	Dict=True,					a_ :	Optional[Any]=True,					a_ :	Any=True,					a_ :	Optional[int]=99,					a_ :	Optional[Any]=32,					a_ :	Optional[Any]=32,					a_ :	Optional[Any]=5,					a_ :	Optional[Any]=4,					a_ :	List[Any]=37,					a_ :	Dict=0.1,					a_ :	Tuple=0.1,					a_ :	List[Any]=512,					a_ :	Union[str, Any]=0.02,					a_ :	Tuple=0,					a_ :	List[Any]=None,					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						parent
      UpperCamelCase__ 						=						batch_size
      UpperCamelCase__ 						=						seq_length
      UpperCamelCase__ 						=						is_training
      UpperCamelCase__ 						=						use_input_mask
      UpperCamelCase__ 						=						use_labels
      UpperCamelCase__ 						=						vocab_size
      UpperCamelCase__ 						=						hidden_size
      UpperCamelCase__ 						=						projection_dim
      UpperCamelCase__ 						=						num_hidden_layers
      UpperCamelCase__ 						=						num_attention_heads
      UpperCamelCase__ 						=						intermediate_size
      UpperCamelCase__ 						=						dropout
      UpperCamelCase__ 						=						attention_dropout
      UpperCamelCase__ 						=						max_position_embeddings
      UpperCamelCase__ 						=						initializer_range
      UpperCamelCase__ 						=						scope
      UpperCamelCase__ 						=						bos_token_id
  
   def 		lowercase_						( self :	int					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						ids_tensor([self.batch_size, self.seq_length],					self.vocab_size					)
  
      UpperCamelCase__ 						=						None
      if self.use_input_mask:
         UpperCamelCase__ 						=						random_attention_mask([self.batch_size, self.seq_length]					)
  
      if input_mask is not None:
         UpperCamelCase__						,		UpperCamelCase__ 						=						input_mask.shape
         UpperCamelCase__ 						=						np.random.randint(1,					seq_length - 1,					size=(batch_size,)					)
         for batch_idx, start_index in enumerate(a_					):
            UpperCamelCase__ 						=						1
            UpperCamelCase__ 						=						0
  
      UpperCamelCase__ 						=						self.get_config()
  
      return config, input_ids, input_mask
  
   def 		lowercase_						( self :	Any					):
  
  
  
  
  
      """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 		lowercase_						( self :	List[str],					a_ :	Optional[Any],					a_ :	int,					a_ :	Optional[int]					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						BlipTextModel(config=a_					)
      model.to(a_					)
      model.eval()
      with torch.no_grad():
         UpperCamelCase__ 						=						model(a_,					attention_mask=a_					)
         UpperCamelCase__ 						=						model(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 		lowercase_						( self :	Optional[int]					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						self.prepare_config_and_inputs()
      UpperCamelCase__						,		UpperCamelCase__						,		UpperCamelCase__ 						=						config_and_inputs
      UpperCamelCase__ 						=						{"input_ids": input_ids, "attention_mask": input_mask}
      return config, inputs_dict
  
  
  
  
  
  
  
  @require_torch
  class  UpperCAmelCase (       SCREAMING_SNAKE_CASE__		,			unittest.TestCase):
   _lowerCamelCase :					Any    					=					(BlipTextModel,) if is_torch_available() else ()
   _lowerCamelCase :					List[Any]    					=					False
   _lowerCamelCase :					Dict    					=					False
   _lowerCamelCase :					int    					=					False
  
   def 		lowercase_						( self :	Dict					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						BlipTextModelTester(self					)
      UpperCamelCase__ 						=						ConfigTester(self,					config_class=a_,					hidden_size=37					)
  
   def 		lowercase_						( self :	int					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      self.config_tester.run_common_tests()
  
   def 		lowercase_						( self :	List[str]					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*a_					)
  
   def 		lowercase_						( self :	Optional[int]					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      pass
  
   def 		lowercase_						( self :	Any					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      pass
  
   @unittest.skip(reason="Blip does not use inputs_embeds"					)
   def 		lowercase_						( self :	Any					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      pass
  
   @unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"					)
   def 		lowercase_						( self :	str					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      pass
  
   @unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"					)
   def 		lowercase_						( self :	Dict					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      pass
  
   @slow
   def 		lowercase_						( self :	Dict					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         UpperCamelCase__ 						=						BlipTextModel.from_pretrained(a_					)
         self.assertIsNotNone(a_					)
  
   def 		lowercase_						( self :	str					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      super().test_pt_tf_model_equivalence(allow_missing_keys=a_					)
style_context: 
  
  
  '''simple docstring'''
  
  from transformers import SqueezeBertTokenizer, SqueezeBertTokenizerFast
  from transformers.testing_utils import require_tokenizers, slow
  
  from ..bert.test_tokenization_bert import BertTokenizationTest
  
  
  
  
  
  
  
  @require_tokenizers
  class  UpperCAmelCase (       SCREAMING_SNAKE_CASE__):
   _lowerCamelCase :					Optional[int]    					=					SqueezeBertTokenizer
   _lowerCamelCase :					List[Any]    					=					SqueezeBertTokenizerFast
   _lowerCamelCase :					int    					=					True
  
   def 		lowercase_						( self :	List[str],					**a_ :	str					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      return SqueezeBertTokenizerFast.from_pretrained(self.tmpdirname,					**a_					)
  
   @slow
   def 		lowercase_						( self :	int					):
  
  
  
  
  
      """simple docstring"""
  
  
  
      UpperCamelCase__ 						=						SqueezeBertTokenizer.from_pretrained("squeezebert/squeezebert-mnli-headless"					)
  
      UpperCamelCase__ 						=						tokenizer.encode("sequence builders",					add_special_tokens=a_					)
      UpperCamelCase__ 						=						tokenizer.encode("multi-sequence build",					add_special_tokens=a_					)
  
      UpperCamelCase__ 						=						tokenizer.build_inputs_with_special_tokens(a_					)
      UpperCamelCase__ 						=						tokenizer.build_inputs_with_special_tokens(a_,					a_					)
  
      assert encoded_sentence == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]
      assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [
          tokenizer.sep_token_id
      ]