code: 
  
  
  
  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_						:
  
        '''simple docstring'''
  
  
  
  
        def __init__(					self   ,							_A   ,							_A=12   ,							_A=7   ,							_A=True   ,							_A=True   ,							_A=True   ,							_A=99   ,							_A=32   ,							_A=32   ,							_A=5   ,							_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.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, input_mask
  
  
  
  
  
  
        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								=      BlipTextModel(config=_A	)
               model.to(_A	)
               model.eval()
               with torch.no_grad():
                      __SCREAMING_SNAKE_CASE								=      model(_A   ,							attention_mask=_A	)
                      __SCREAMING_SNAKE_CASE								=      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  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               __SCREAMING_SNAKE_CASE								=      self.prepare_config_and_inputs()
               __SCREAMING_SNAKE_CASE								=      config_and_inputs
               __SCREAMING_SNAKE_CASE								=      {'''input_ids''': input_ids, '''attention_mask''': input_mask}
               return config, inputs_dict
  
  
  
  
  
  
  
  @require_torch
  class      UpperCAmelCase_						(     UpperCamelCase_					,					unittest.TestCase ):
  
        '''simple docstring'''
  
  
  
  
        UpperCamelCase__    :				Any       						=						(BlipTextModel,) if is_torch_available() else ()
        UpperCamelCase__    :				Tuple       						=						False
        UpperCamelCase__    :				Dict       						=						False
        UpperCamelCase__    :				Dict       						=						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 BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                      __SCREAMING_SNAKE_CASE								=      BlipTextModel.from_pretrained(_A	)
                      self.assertIsNotNone(_A	)
  
  
  
  
  
  
        def  _A			(					self	):
  
  
  
  
  
  
  
               '''simple docstring'''
  
               super().test_pt_tf_model_equivalence(allow_missing_keys=_A	)
  
  
  
  
  
  
  
style_context: 
  
  
  
  from __future__ import annotations
  
  from collections.abc import Iterable
  from dataclasses import dataclass
  from typing import Any
  
  class      UpperCAmelCase_						:
  
  						'''simple docstring'''
  
  
  
  
  						UpperCamelCase__    :				List[str]       						=						('''_front''', '''_back''', '''_len''')
  
  						@dataclass
  						class      UpperCAmelCase_						:
  
  												'''simple docstring'''
  
  
  
  
  												UpperCamelCase__    :				Any       						=						None
  												UpperCamelCase__    :				Deque._Node | None       						=						None
  												UpperCamelCase__    :				Deque._Node | None       						=						None
  
  
  
  
  
  
  
  						class      UpperCAmelCase_						:
  
  												'''simple docstring'''
  
  
  
  
  												UpperCamelCase__    :				Optional[int]       						=						('''_cur''',)
  
  
  
  
  
  
  												def __init__(					self   ,							_A	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			__SCREAMING_SNAKE_CASE								=      cur
  
  
  
  
  
  
  												def __iter__(					self	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			return self
  
  
  
  
  
  
  												def  _A			(					self	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			if self._cur is None:
  																										# finished iterating
  																										raise StopIteration
  																			__SCREAMING_SNAKE_CASE								=      self._cur.val
  																			__SCREAMING_SNAKE_CASE								=      self._cur.next_node
  
  																			return val
  
  
  
  
  
  
  
  						def __init__(					self   ,							_A = None	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      0
  
  													if iterable is not None:
  																				# append every value to the deque
  																				for val in iterable:
  																											self.append(_A	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      self._Node(_A   ,							_A   ,							_A	)
  													if self.is_empty():
  																				# front = back
  																				__SCREAMING_SNAKE_CASE								=      __SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      1
  													else:
  																				# connect nodes
  																				__SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      self._back
  																				__SCREAMING_SNAKE_CASE								=      node  # assign new back to the new node
  
  																				self._len += 1
  
  																				# make sure there were no errors
  																				assert not self.is_empty(), "Error on appending value."
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      self._Node(_A   ,							_A   ,							_A	)
  													if self.is_empty():
  																				# front = back
  																				__SCREAMING_SNAKE_CASE								=      __SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      1
  													else:
  																				# connect nodes
  																				__SCREAMING_SNAKE_CASE								=      self._front
  																				__SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      node  # assign new front to the new node
  
  																				self._len += 1
  
  																				# make sure there were no errors
  																				assert not self.is_empty(), "Error on appending value."
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													for val in iterable:
  																				self.append(_A	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													for val in iterable:
  																				self.appendleft(_A	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													assert not self.is_empty(), "Deque is empty."
  
  													__SCREAMING_SNAKE_CASE								=      self._back
  													__SCREAMING_SNAKE_CASE								=      self._back.prev_node  # set new back
  													# drop the last node - python will deallocate memory automatically
  													__SCREAMING_SNAKE_CASE								=      None
  
  													self._len -= 1
  
  													return topop.val
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													assert not self.is_empty(), "Deque is empty."
  
  													__SCREAMING_SNAKE_CASE								=      self._front
  													__SCREAMING_SNAKE_CASE								=      self._front.next_node  # set new front and drop the first node
  													__SCREAMING_SNAKE_CASE								=      None
  
  													self._len -= 1
  
  													return topop.val
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._front is None
  
  
  
  
  
  
  						def __len__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._len
  
  
  
  
  
  
  						def __eq__(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if not isinstance(_A   ,							_A	):
  																				return NotImplemented
  
  													__SCREAMING_SNAKE_CASE								=      self._front
  													__SCREAMING_SNAKE_CASE								=      other._front
  
  													# if the length of the dequeues are not the same, they are not equal
  													if len(self	) != len(_A	):
  																				return False
  
  													while me is not None and oth is not None:
  																				# compare every value
  																				if me.val != oth.val:
  																											return False
  																				__SCREAMING_SNAKE_CASE								=      me.next_node
  																				__SCREAMING_SNAKE_CASE								=      oth.next_node
  
  													return True
  
  
  
  
  
  
  						def __iter__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return Deque._Iterator(self._front	)
  
  
  
  
  
  
  						def __repr__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      []
  													__SCREAMING_SNAKE_CASE								=      self._front
  													while aux is not None:
  																				# append the values in a list to display
  																				values_list.append(aux.val	)
  																				__SCREAMING_SNAKE_CASE								=      aux.next_node
  
  													return f"""[{", ".join(repr(_A	) for val in values_list	)}]"""
  
  
  if __name__ == "__main__":
  			import doctest
  
  			doctest.testmod()
  
  
  
  
  
  
  