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   a_  :
  
  
  
  
  							def __init__(     self   ,   snake_case_   ,   snake_case_=1_2   ,   snake_case_=7   ,   snake_case_=True   ,   snake_case_=True   ,   snake_case_=True   ,   snake_case_=9_9   ,   snake_case_=3_2   ,   snake_case_=3_2   ,   snake_case_=5   ,   snake_case_=4   ,   snake_case_=3_7   ,   snake_case_=0.1   ,   snake_case_=0.1   ,   snake_case_=5_1_2   ,   snake_case_=0.02   ,   snake_case_=0   ,   snake_case_=None   ,   ):
  									_lowerCAmelCase       :  str   				=					parent
  									_lowerCAmelCase       :  Any   				=					batch_size
  									_lowerCAmelCase       :  List[str]   				=					seq_length
  									_lowerCAmelCase       :  Any   				=					is_training
  									_lowerCAmelCase       :  Union[str, Any]   				=					use_input_mask
  									_lowerCAmelCase       :  Optional[Any]   				=					use_labels
  									_lowerCAmelCase       :  int   				=					vocab_size
  									_lowerCAmelCase       :  int   				=					hidden_size
  									_lowerCAmelCase       :  Dict   				=					projection_dim
  									_lowerCAmelCase       :  Dict   				=					num_hidden_layers
  									_lowerCAmelCase       :  Any   				=					num_attention_heads
  									_lowerCAmelCase       :  Any   				=					intermediate_size
  									_lowerCAmelCase       :  Tuple   				=					dropout
  									_lowerCAmelCase       :  Union[str, Any]   				=					attention_dropout
  									_lowerCAmelCase       :  Tuple   				=					max_position_embeddings
  									_lowerCAmelCase       :  Union[str, Any]   				=					initializer_range
  									_lowerCAmelCase       :  Optional[Any]   				=					scope
  									_lowerCAmelCase       :  Any   				=					bos_token_id
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									_lowerCAmelCase       :  Dict   				=					ids_tensor([self.batch_size, self.seq_length]   ,   self.vocab_size  )
  
  									_lowerCAmelCase       :  List[Any]   				=					None
  									if self.use_input_mask:
  											_lowerCAmelCase       :  Optional[Any]   				=					random_attention_mask([self.batch_size, self.seq_length]  )
  
  									if input_mask is not None:
  											_lowerCAmelCase       :  int   				=					input_mask.shape
  											_lowerCAmelCase       :  Optional[Any]   				=					np.random.randint(1   ,   seq_length - 1   ,   size=(batch_size,)  )
  											for batch_idx, start_index in enumerate(snake_case_  ):
  													_lowerCAmelCase       :  Optional[int]   				=					1
  													_lowerCAmelCase       :  Dict   				=					0
  
  									_lowerCAmelCase       :  Optional[Any]   				=					self.get_config()
  
  									return config, input_ids, input_mask
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									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   ,   snake_case_   ,   snake_case_   ,   snake_case_  ):
  									_lowerCAmelCase       :  List[str]   				=					BlipTextModel(config=snake_case_  )
  									model.to(snake_case_  )
  									model.eval()
  									with torch.no_grad():
  											_lowerCAmelCase       :  str   				=					model(snake_case_   ,   attention_mask=snake_case_  )
  											_lowerCAmelCase       :  Tuple   				=					model(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  ):
  									_lowerCAmelCase       :  Optional[int]   				=					self.prepare_config_and_inputs()
  									_lowerCAmelCase       :  str   				=					config_and_inputs
  									_lowerCAmelCase       :  Optional[int]   				=					{"""input_ids""": input_ids, """attention_mask""": input_mask}
  									return config, inputs_dict
  
  
  
  @require_torch
  class   a_  (_a							,			unittest.TestCase    ):
  							__lowerCAmelCase    :				int    =      (BlipTextModel,) if is_torch_available() else ()
  							__lowerCAmelCase    :				Tuple    =      False
  							__lowerCAmelCase    :				List[Any]    =      False
  							__lowerCAmelCase    :				Dict    =      False
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									_lowerCAmelCase       :  str   				=					BlipTextModelTester(self  )
  									_lowerCAmelCase       :  str   				=					ConfigTester(self   ,   config_class=snake_case_   ,   hidden_size=3_7  )
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									self.config_tester.run_common_tests()
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									_lowerCAmelCase       :  Any   				=					self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_model(*snake_case_  )
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									pass
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									pass
  
  
  
  
  							@unittest.skip(reason="""Blip does not use inputs_embeds"""  )
  							def 							__UpperCamelCase       (     self  ):
  									pass
  
  
  
  
  							@unittest.skip(reason="""BlipTextModel has no base class and is not available in MODEL_MAPPING"""  )
  							def 							__UpperCamelCase       (     self  ):
  									pass
  
  
  
  
  							@unittest.skip(reason="""BlipTextModel has no base class and is not available in MODEL_MAPPING"""  )
  							def 							__UpperCamelCase       (     self  ):
  									pass
  
  
  
  
  							@slow
  							def 							__UpperCamelCase       (     self  ):
  									for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
  											_lowerCAmelCase       :  Optional[int]   				=					BlipTextModel.from_pretrained(snake_case_  )
  											self.assertIsNotNone(snake_case_  )
  
  
  
  
  
  
  
  							def 							__UpperCamelCase       (     self  ):
  									super().test_pt_tf_model_equivalence(allow_missing_keys=snake_case_  )
  
  
  
style_context: 
  '''simple docstring'''
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  
  
  UpperCamelCase_     			=       {
      """configuration_deformable_detr""": ["""DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeformableDetrConfig"""],
  }
  
  try:
       if not is_vision_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       UpperCamelCase_     			=       ["""DeformableDetrFeatureExtractor"""]
       UpperCamelCase_     			=       ["""DeformableDetrImageProcessor"""]
  
  try:
       if not is_torch_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       UpperCamelCase_     			=       [
           """DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """DeformableDetrForObjectDetection""",
           """DeformableDetrModel""",
           """DeformableDetrPreTrainedModel""",
       ]
  
  
  if TYPE_CHECKING:
       from .configuration_deformable_detr import DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DeformableDetrConfig
  
       try:
            if not is_vision_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .feature_extraction_deformable_detr import DeformableDetrFeatureExtractor
            from .image_processing_deformable_detr import DeformableDetrImageProcessor
  
       try:
            if not is_torch_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .modeling_deformable_detr import (
                DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST,
                DeformableDetrForObjectDetection,
                DeformableDetrModel,
                DeformableDetrPreTrainedModel,
            )
  
  else:
       import sys
  
       UpperCamelCase_     			=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
  
  
  