






"""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				:    Optional[Any]    ,     __lowerCamelCase				:    Optional[Any]    ,     __lowerCamelCase				:    Dict=1_2    ,     __lowerCamelCase				:    List[str]=7    ,     __lowerCamelCase				:    Optional[int]=True    ,     __lowerCamelCase				:    Optional[Any]=True    ,     __lowerCamelCase				:    Union[str, Any]=True    ,     __lowerCamelCase				:    Optional[int]=9_9    ,     __lowerCamelCase				:    Union[str, Any]=3_2    ,     __lowerCamelCase				:    str=3_2    ,     __lowerCamelCase				:    List[str]=5    ,     __lowerCamelCase				:    Optional[Any]=4    ,     __lowerCamelCase				:    List[Any]=3_7    ,     __lowerCamelCase				:    List[Any]=0.1    ,     __lowerCamelCase				:    Optional[int]=0.1    ,     __lowerCamelCase				:    List[Any]=5_1_2    ,     __lowerCamelCase				:    Optional[Any]=0.02    ,     __lowerCamelCase				:    Tuple=0    ,     __lowerCamelCase				:    Union[str, Any]=None    ,     )					->       Any:
										__magic_name__      =  parent
										__magic_name__      =  batch_size
										__magic_name__      =  seq_length
										__magic_name__      =  is_training
										__magic_name__      =  use_input_mask
										__magic_name__      =  use_labels
										__magic_name__      =  vocab_size
										__magic_name__      =  hidden_size
										__magic_name__      =  projection_dim
										__magic_name__      =  num_hidden_layers
										__magic_name__      =  num_attention_heads
										__magic_name__      =  intermediate_size
										__magic_name__      =  dropout
										__magic_name__      =  attention_dropout
										__magic_name__      =  max_position_embeddings
										__magic_name__      =  initializer_range
										__magic_name__      =  scope
										__magic_name__      =  bos_token_id







				def      _snake_case       (				self				:    Union[str, Any]						)					->       Tuple:
										__magic_name__      =  ids_tensor([self.batch_size, self.seq_length]    ,     self.vocab_size						)

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

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

										__magic_name__      =  self.get_config()

										return config, input_ids, input_mask







				def      _snake_case       (				self				:    Any						)					->       Dict:
										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      _snake_case       (				self				:    Union[str, Any]    ,     __lowerCamelCase				:    str    ,     __lowerCamelCase				:    Tuple    ,     __lowerCamelCase				:    Tuple						)					->       Optional[int]:
										__magic_name__      =  BlipTextModel(config=lowerCamelCase__						)
										model.to(lowerCamelCase__						)
										model.eval()
										with torch.no_grad():
																__magic_name__      =  model(lowerCamelCase__    ,     attention_mask=lowerCamelCase__						)
																__magic_name__      =  model(lowerCamelCase__						)
										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      _snake_case       (				self				:    Dict						)					->       Union[str, Any]:
										__magic_name__      =  self.prepare_config_and_inputs()
										__magic_name__      =  config_and_inputs
										__magic_name__      =  {"input_ids": input_ids, "attention_mask": input_mask}
										return config, inputs_dict





@require_torch
class     A_				(   _lowercase       ,				unittest.TestCase	):
				UpperCAmelCase__										=					(BlipTextModel,) if is_torch_available() else ()
				UpperCAmelCase__										=					False
				UpperCAmelCase__										=					False
				UpperCAmelCase__										=					False







				def      _snake_case       (				self				:    Optional[int]						)					->       Tuple:
										__magic_name__      =  BlipTextModelTester(self						)
										__magic_name__      =  ConfigTester(self    ,     config_class=lowerCamelCase__    ,     hidden_size=3_7						)







				def      _snake_case       (				self				:    Optional[int]						)					->       str:
										self.config_tester.run_common_tests()







				def      _snake_case       (				self				:    str						)					->       Dict:
										__magic_name__      =  self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowerCamelCase__						)







				def      _snake_case       (				self				:    List[str]						)					->       Union[str, Any]:
										pass







				def      _snake_case       (				self				:    Tuple						)					->       Optional[Any]:
										pass







				@unittest.skip(reason="Blip does not use inputs_embeds"						)
				def      _snake_case       (				self				:    int						)					->       str:
										pass







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







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







				@slow
				def      _snake_case       (				self				:    Any						)					->       List[str]:




										for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																__magic_name__      =  BlipTextModel.from_pretrained(lowerCamelCase__						)
																self.assertIsNotNone(lowerCamelCase__						)







				def      _snake_case       (				self				:    Any						)					->       str:
										super().test_pt_tf_model_equivalence(allow_missing_keys=lowerCamelCase__						)







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


lowercase  		=			{
    """configuration_flaubert""": ["""FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FlaubertConfig""", """FlaubertOnnxConfig"""],
    """tokenization_flaubert""": ["""FlaubertTokenizer"""],
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowercase  		=			[
					    """FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """FlaubertForMultipleChoice""",
					    """FlaubertForQuestionAnswering""",
					    """FlaubertForQuestionAnsweringSimple""",
					    """FlaubertForSequenceClassification""",
					    """FlaubertForTokenClassification""",
					    """FlaubertModel""",
					    """FlaubertWithLMHeadModel""",
					    """FlaubertPreTrainedModel""",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowercase  		=			[
					    """TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """TFFlaubertForMultipleChoice""",
					    """TFFlaubertForQuestionAnsweringSimple""",
					    """TFFlaubertForSequenceClassification""",
					    """TFFlaubertForTokenClassification""",
					    """TFFlaubertModel""",
					    """TFFlaubertPreTrainedModel""",
					    """TFFlaubertWithLMHeadModel""",
					]


if TYPE_CHECKING:
					from .configuration_flaubert import FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, FlaubertConfig, FlaubertOnnxConfig
					from .tokenization_flaubert import FlaubertTokenizer

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_flaubert import (
										    FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    FlaubertForMultipleChoice,
										    FlaubertForQuestionAnswering,
										    FlaubertForQuestionAnsweringSimple,
										    FlaubertForSequenceClassification,
										    FlaubertForTokenClassification,
										    FlaubertModel,
										    FlaubertPreTrainedModel,
										    FlaubertWithLMHeadModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_flaubert import (
										    TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFFlaubertForMultipleChoice,
										    TFFlaubertForQuestionAnsweringSimple,
										    TFFlaubertForSequenceClassification,
										    TFFlaubertForTokenClassification,
										    TFFlaubertModel,
										    TFFlaubertPreTrainedModel,
										    TFFlaubertWithLMHeadModel,
										)

else:
					import sys

					lowercase  		=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





