



'''simple docstring'''

import unittest

from transformers import DebertaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    DebertaForMaskedLM,
		    DebertaForQuestionAnswering,
		    DebertaForSequenceClassification,
		    DebertaForTokenClassification,
		    DebertaModel,
		)
		from transformers.models.deberta.modeling_deberta import DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST



class 		lowerCamelCase__      (						A     ):




					'''simple docstring'''



					def __init__(  self				:	str     ,  UpperCamelCase_				:	str     ,  UpperCamelCase_				:	int=13     ,  UpperCamelCase_				:	List[Any]=7     ,  UpperCamelCase_				:	int=True     ,  UpperCamelCase_				:	Optional[int]=True     ,  UpperCamelCase_				:	List[Any]=True     ,  UpperCamelCase_				:	List[Any]=True     ,  UpperCamelCase_				:	Any=99     ,  UpperCamelCase_				:	str=32     ,  UpperCamelCase_				:	List[Any]=5     ,  UpperCamelCase_				:	int=4     ,  UpperCamelCase_				:	List[str]=37     ,  UpperCamelCase_				:	List[Any]="gelu"     ,  UpperCamelCase_				:	List[Any]=0.1     ,  UpperCamelCase_				:	str=0.1     ,  UpperCamelCase_				:	Dict=512     ,  UpperCamelCase_				:	Any=16     ,  UpperCamelCase_				:	str=2     ,  UpperCamelCase_				:	List[Any]=0.02     ,  UpperCamelCase_				:	List[str]=False     ,  UpperCamelCase_				:	List[str]=True     ,  UpperCamelCase_				:	Union[str, Any]="None"     ,  UpperCamelCase_				:	Union[str, Any]=3     ,  UpperCamelCase_				:	Optional[int]=4     ,  UpperCamelCase_				:	List[str]=None     ,  )  ->       str:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		parent
						_lowercase					:       int       =		batch_size
						_lowercase					:       Any       =		seq_length
						_lowercase					:       List[str]       =		is_training
						_lowercase					:       Optional[Any]       =		use_input_mask
						_lowercase					:       Any       =		use_token_type_ids
						_lowercase					:       List[str]       =		use_labels
						_lowercase					:       List[str]       =		vocab_size
						_lowercase					:       Tuple       =		hidden_size
						_lowercase					:       List[Any]       =		num_hidden_layers
						_lowercase					:       List[str]       =		num_attention_heads
						_lowercase					:       List[str]       =		intermediate_size
						_lowercase					:       List[Any]       =		hidden_act
						_lowercase					:       Any       =		hidden_dropout_prob
						_lowercase					:       List[str]       =		attention_probs_dropout_prob
						_lowercase					:       Dict       =		max_position_embeddings
						_lowercase					:       Optional[Any]       =		type_vocab_size
						_lowercase					:       str       =		type_sequence_label_size
						_lowercase					:       Any       =		initializer_range
						_lowercase					:       Union[str, Any]       =		num_labels
						_lowercase					:       Any       =		num_choices
						_lowercase					:       Any       =		relative_attention
						_lowercase					:       str       =		position_biased_input
						_lowercase					:       str       =		pos_att_type
						_lowercase					:       Union[str, Any]       =		scope




					def 						__UpperCAmelCase     (  self				:	Dict					)  ->       str:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		ids_tensor([self.batch_size, self.seq_length]     ,  self.vocab_size					)

						_lowercase					:       Dict       =		None
						if self.use_input_mask:
							_lowercase					:       Optional[Any]       =		ids_tensor([self.batch_size, self.seq_length]     ,  vocab_size=2					)

						_lowercase					:       int       =		None
						if self.use_token_type_ids:
							_lowercase					:       int       =		ids_tensor([self.batch_size, self.seq_length]     ,  self.type_vocab_size					)

						_lowercase					:       Tuple       =		None
						_lowercase					:       Union[str, Any]       =		None
						_lowercase					:       List[Any]       =		None
						if self.use_labels:
							_lowercase					:       Dict       =		ids_tensor([self.batch_size]     ,  self.type_sequence_label_size					)
							_lowercase					:       List[str]       =		ids_tensor([self.batch_size, self.seq_length]     ,  self.num_labels					)
							_lowercase					:       List[str]       =		ids_tensor([self.batch_size]     ,  self.num_choices					)

						_lowercase					:       str       =		self.get_config()

						return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Tuple:



						'''simple docstring'''





						return DebertaConfig(
						    vocab_size=self.vocab_size     ,  hidden_size=self.hidden_size     ,  num_hidden_layers=self.num_hidden_layers     ,  num_attention_heads=self.num_attention_heads     ,  intermediate_size=self.intermediate_size     ,  hidden_act=self.hidden_act     ,  hidden_dropout_prob=self.hidden_dropout_prob     ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob     ,  max_position_embeddings=self.max_position_embeddings     ,  type_vocab_size=self.type_vocab_size     ,  initializer_range=self.initializer_range     ,  relative_attention=self.relative_attention     ,  position_biased_input=self.position_biased_input     ,  pos_att_type=self.pos_att_type     ,  )




					def 						__UpperCAmelCase     (  self				:	Optional[Any]					)  ->       int:



						'''simple docstring'''





						_lowercase					:       str       =		self.get_config()
						_lowercase					:       Union[str, Any]       =		300
						return config




					def 						__UpperCAmelCase     (  self				:	Optional[Any]     ,  UpperCamelCase_				:	Any					)  ->       Tuple:



						'''simple docstring'''





						self.parent.assertListEqual(list(result.loss.size()					)     ,  []					)




					def 						__UpperCAmelCase     (  self				:	Tuple     ,  UpperCamelCase_				:	Dict     ,  UpperCamelCase_				:	List[str]     ,  UpperCamelCase_				:	int     ,  UpperCamelCase_				:	List[Any]     ,  UpperCamelCase_				:	List[Any]     ,  UpperCamelCase_				:	Optional[int]     ,  UpperCamelCase_				:	str					)  ->       Any:



						'''simple docstring'''





						_lowercase					:       List[str]       =		DebertaModel(config=UpperCamelCase_					)
						model.to(UpperCamelCase_					)
						model.eval()
						_lowercase					:       Tuple       =		model(UpperCamelCase_     ,  attention_mask=UpperCamelCase_     ,  token_type_ids=UpperCamelCase_					)[0]
						_lowercase					:       List[str]       =		model(UpperCamelCase_     ,  token_type_ids=UpperCamelCase_					)[0]
						_lowercase					:       List[str]       =		model(UpperCamelCase_					)[0]

						self.parent.assertListEqual(list(sequence_output.size()					)     ,  [self.batch_size, self.seq_length, self.hidden_size]					)




					def 						__UpperCAmelCase     (  self				:	int     ,  UpperCamelCase_				:	Optional[int]     ,  UpperCamelCase_				:	Optional[Any]     ,  UpperCamelCase_				:	str     ,  UpperCamelCase_				:	List[Any]     ,  UpperCamelCase_				:	Optional[Any]     ,  UpperCamelCase_				:	Tuple     ,  UpperCamelCase_				:	List[Any]					)  ->       str:



						'''simple docstring'''





						_lowercase					:       Tuple       =		DebertaForMaskedLM(config=UpperCamelCase_					)
						model.to(UpperCamelCase_					)
						model.eval()
						_lowercase					:       Union[str, Any]       =		model(UpperCamelCase_     ,  attention_mask=UpperCamelCase_     ,  token_type_ids=UpperCamelCase_     ,  labels=UpperCamelCase_					)

						self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.vocab_size)					)




					def 						__UpperCAmelCase     (  self				:	Union[str, Any]     ,  UpperCamelCase_				:	List[Any]     ,  UpperCamelCase_				:	Optional[int]     ,  UpperCamelCase_				:	Any     ,  UpperCamelCase_				:	str     ,  UpperCamelCase_				:	str     ,  UpperCamelCase_				:	Any     ,  UpperCamelCase_				:	List[Any]					)  ->       str:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		self.num_labels
						_lowercase					:       Union[str, Any]       =		DebertaForSequenceClassification(UpperCamelCase_					)
						model.to(UpperCamelCase_					)
						model.eval()
						_lowercase					:       Union[str, Any]       =		model(UpperCamelCase_     ,  attention_mask=UpperCamelCase_     ,  token_type_ids=UpperCamelCase_     ,  labels=UpperCamelCase_					)
						self.parent.assertListEqual(list(result.logits.size()					)     ,  [self.batch_size, self.num_labels]					)
						self.check_loss_output(UpperCamelCase_					)




					def 						__UpperCAmelCase     (  self				:	Union[str, Any]     ,  UpperCamelCase_				:	Dict     ,  UpperCamelCase_				:	Union[str, Any]     ,  UpperCamelCase_				:	Dict     ,  UpperCamelCase_				:	Tuple     ,  UpperCamelCase_				:	Tuple     ,  UpperCamelCase_				:	Any     ,  UpperCamelCase_				:	str					)  ->       Dict:



						'''simple docstring'''





						_lowercase					:       str       =		self.num_labels
						_lowercase					:       Tuple       =		DebertaForTokenClassification(config=UpperCamelCase_					)
						model.to(UpperCamelCase_					)
						model.eval()
						_lowercase					:       int       =		model(UpperCamelCase_     ,  attention_mask=UpperCamelCase_     ,  token_type_ids=UpperCamelCase_     ,  labels=UpperCamelCase_					)
						self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.num_labels)					)




					def 						__UpperCAmelCase     (  self				:	Union[str, Any]     ,  UpperCamelCase_				:	Any     ,  UpperCamelCase_				:	Optional[int]     ,  UpperCamelCase_				:	Dict     ,  UpperCamelCase_				:	List[Any]     ,  UpperCamelCase_				:	Any     ,  UpperCamelCase_				:	Tuple     ,  UpperCamelCase_				:	List[str]					)  ->       Dict:



						'''simple docstring'''





						_lowercase					:       Dict       =		DebertaForQuestionAnswering(config=UpperCamelCase_					)
						model.to(UpperCamelCase_					)
						model.eval()
						_lowercase					:       Optional[Any]       =		model(
						    UpperCamelCase_     ,  attention_mask=UpperCamelCase_     ,  token_type_ids=UpperCamelCase_     ,  start_positions=UpperCamelCase_     ,  end_positions=UpperCamelCase_     ,  )
						self.parent.assertEqual(result.start_logits.shape     ,  (self.batch_size, self.seq_length)					)
						self.parent.assertEqual(result.end_logits.shape     ,  (self.batch_size, self.seq_length)					)




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       List[Any]:



						'''simple docstring'''





						_lowercase					:       Union[str, Any]       =		self.prepare_config_and_inputs()
						(
						    (
						    _lowercase
						)  ,    (
						    _lowercase
						)  ,    (
						    _lowercase
						)  ,    (
						    _lowercase
						)  ,    (
						    _lowercase
						)  ,    (
						    _lowercase
						)  ,    (
						    _lowercase
						)  ,    
						)					:       int       =		config_and_inputs
						_lowercase					:       Dict       =		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
						return config, inputs_dict






@require_torch
class 		lowerCamelCase__      (						A	,   A	,   unittest.TestCase     ):




					'''simple docstring'''



					A_						    =						(
					    (
					        DebertaModel,
					        DebertaForMaskedLM,
					        DebertaForSequenceClassification,
					        DebertaForTokenClassification,
					        DebertaForQuestionAnswering,
					    )
					    if is_torch_available()
					    else ()
					)
					A_						    =						(
					    {
					        """feature-extraction""": DebertaModel,
					        """fill-mask""": DebertaForMaskedLM,
					        """question-answering""": DebertaForQuestionAnswering,
					        """text-classification""": DebertaForSequenceClassification,
					        """token-classification""": DebertaForTokenClassification,
					        """zero-shot""": DebertaForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)

					A_						    =						True
					A_						    =						False
					A_						    =						False
					A_						    =						False
					A_						    =						False




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Dict:



						'''simple docstring'''





						_lowercase					:       str       =		DebertaModelTester(self					)
						_lowercase					:       str       =		ConfigTester(self     ,  config_class=UpperCamelCase_     ,  hidden_size=37					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       Union[str, Any]:



						'''simple docstring'''





						self.config_tester.run_common_tests()




					def 						__UpperCAmelCase     (  self				:	List[str]					)  ->       str:



						'''simple docstring'''





						_lowercase					:       Optional[Any]       =		self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_deberta_model(*UpperCamelCase_					)




					def 						__UpperCAmelCase     (  self				:	Optional[Any]					)  ->       Optional[Any]:



						'''simple docstring'''





						_lowercase					:       Dict       =		self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_deberta_for_sequence_classification(*UpperCamelCase_					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       Union[str, Any]:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_deberta_for_masked_lm(*UpperCamelCase_					)




					def 						__UpperCAmelCase     (  self				:	Union[str, Any]					)  ->       Any:



						'''simple docstring'''





						_lowercase					:       str       =		self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_deberta_for_question_answering(*UpperCamelCase_					)




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Tuple:



						'''simple docstring'''





						_lowercase					:       Tuple       =		self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_deberta_for_token_classification(*UpperCamelCase_					)




					@slow
					def 						__UpperCAmelCase     (  self				:	int					)  ->       Optional[int]:



						'''simple docstring'''





						for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							_lowercase					:       Tuple       =		DebertaModel.from_pretrained(UpperCamelCase_					)
							self.assertIsNotNone(UpperCamelCase_					)






@require_torch
@require_sentencepiece
@require_tokenizers
class 		lowerCamelCase__      (						unittest.TestCase     ):




					'''simple docstring'''



					@unittest.skip(reason='Model not available yet'					)
					def 						__UpperCAmelCase     (  self				:	Optional[int]					)  ->       Union[str, Any]:



						'''simple docstring'''





						pass




					@slow
					def 						__UpperCAmelCase     (  self				:	Optional[int]					)  ->       Any:



						'''simple docstring'''





						_lowercase					:       List[str]       =		DebertaModel.from_pretrained('microsoft/deberta-base'					)

						_lowercase					:       Any       =		torch.tensor([[0, 3_1414, 232, 328, 740, 1140, 1_2695, 69, 4_6078, 1588, 2]]					)
						_lowercase					:       List[str]       =		torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]					)
						with torch.no_grad():
							_lowercase					:       List[str]       =		model(UpperCamelCase_     ,  attention_mask=UpperCamelCase_					)[0]
						# compare the actual values for a slice.
						_lowercase					:       Dict       =		torch.tensor(
						    [[[-0.59_86, -0.80_55, -0.84_62], [1.44_84, -0.93_48, -0.80_59], [0.31_23, 0.00_32, -1.41_31]]]					)
						self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     ,  UpperCamelCase_     ,  atol=1E-4					)     ,  F'''{output[:, 1:4, 1:4]}'''					)





'''simple docstring'''

import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


_A				:    int     						=logging.get_logger(__name__)

_A				:    Union[str, Any]     						={
    '''Salesforce/instruct-blip-flan-t5''': '''https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json''',
}



class 		lowerCamelCase__      (						A     ):




					'''simple docstring'''



					A_						    =						"""instructblip_vision_model"""




					def __init__(  self				:	Union[str, Any]     ,  UpperCamelCase_				:	str=1408     ,  UpperCamelCase_				:	Tuple=6144     ,  UpperCamelCase_				:	Union[str, Any]=39     ,  UpperCamelCase_				:	Optional[Any]=16     ,  UpperCamelCase_				:	str=224     ,  UpperCamelCase_				:	Dict=14     ,  UpperCamelCase_				:	Dict="gelu"     ,  UpperCamelCase_				:	int=1E-6     ,  UpperCamelCase_				:	int=0.0     ,  UpperCamelCase_				:	List[str]=1E-10     ,  UpperCamelCase_				:	str=True     ,  **UpperCamelCase_				:	Dict     ,  )  ->       Any:



						'''simple docstring'''





						super().__init__(**UpperCamelCase_					)

						_lowercase					:       Optional[Any]       =		hidden_size
						_lowercase					:       Optional[Any]       =		intermediate_size
						_lowercase					:       Optional[int]       =		num_hidden_layers
						_lowercase					:       str       =		num_attention_heads
						_lowercase					:       Tuple       =		patch_size
						_lowercase					:       Dict       =		image_size
						_lowercase					:       Optional[int]       =		initializer_range
						_lowercase					:       List[Any]       =		attention_dropout
						_lowercase					:       int       =		layer_norm_eps
						_lowercase					:       Optional[int]       =		hidden_act
						_lowercase					:       str       =		qkv_bias




					@classmethod
					def 						__UpperCAmelCase     (  cls				:	List[Any]     ,  UpperCamelCase_				:	Union[str, os.PathLike]     ,  **UpperCamelCase_				:	List[str]					)  ->       "PretrainedConfig":



						'''simple docstring'''





						cls._set_token_in_kwargs(UpperCamelCase_					)

						_lowercase  ,    _lowercase					:       Tuple       =		cls.get_config_dict(UpperCamelCase_     ,  **UpperCamelCase_					)

						# get the vision config dict if we are loading from InstructBlipConfig
						if config_dict.get('model_type'					) == "instructblip":
							_lowercase					:       Any       =		config_dict['vision_config']

						if "model_type" in config_dict and hasattr(cls     ,  'model_type'					) and config_dict["model_type"] != cls.model_type:
							logger.warning(
							    F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
							    F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''					)

						return cls.from_dict(UpperCamelCase_     ,  **UpperCamelCase_					)






class 		lowerCamelCase__      (						A     ):




					'''simple docstring'''



					A_						    =						"""instructblip_qformer"""




					def __init__(  self				:	Tuple     ,  UpperCamelCase_				:	Union[str, Any]=3_0522     ,  UpperCamelCase_				:	Union[str, Any]=768     ,  UpperCamelCase_				:	Tuple=12     ,  UpperCamelCase_				:	Optional[Any]=12     ,  UpperCamelCase_				:	List[str]=3072     ,  UpperCamelCase_				:	List[str]="gelu"     ,  UpperCamelCase_				:	Union[str, Any]=0.1     ,  UpperCamelCase_				:	List[str]=0.1     ,  UpperCamelCase_				:	Any=512     ,  UpperCamelCase_				:	Union[str, Any]=0.02     ,  UpperCamelCase_				:	List[Any]=1E-12     ,  UpperCamelCase_				:	Optional[Any]=0     ,  UpperCamelCase_				:	str="absolute"     ,  UpperCamelCase_				:	List[Any]=2     ,  UpperCamelCase_				:	Any=1408     ,  **UpperCamelCase_				:	Dict     ,  )  ->       Any:



						'''simple docstring'''





						super().__init__(pad_token_id=UpperCamelCase_     ,  **UpperCamelCase_					)

						_lowercase					:       Dict       =		vocab_size
						_lowercase					:       Optional[Any]       =		hidden_size
						_lowercase					:       Any       =		num_hidden_layers
						_lowercase					:       List[Any]       =		num_attention_heads
						_lowercase					:       Optional[int]       =		hidden_act
						_lowercase					:       Union[str, Any]       =		intermediate_size
						_lowercase					:       List[Any]       =		hidden_dropout_prob
						_lowercase					:       Dict       =		attention_probs_dropout_prob
						_lowercase					:       Any       =		max_position_embeddings
						_lowercase					:       Optional[int]       =		initializer_range
						_lowercase					:       Tuple       =		layer_norm_eps
						_lowercase					:       List[str]       =		position_embedding_type
						_lowercase					:       str       =		cross_attention_frequency
						_lowercase					:       int       =		encoder_hidden_size




					@classmethod
					def 						__UpperCAmelCase     (  cls				:	List[Any]     ,  UpperCamelCase_				:	Union[str, os.PathLike]     ,  **UpperCamelCase_				:	List[str]					)  ->       "PretrainedConfig":



						'''simple docstring'''





						cls._set_token_in_kwargs(UpperCamelCase_					)

						_lowercase  ,    _lowercase					:       List[str]       =		cls.get_config_dict(UpperCamelCase_     ,  **UpperCamelCase_					)

						# get the qformer config dict if we are loading from InstructBlipConfig
						if config_dict.get('model_type'					) == "instructblip":
							_lowercase					:       Optional[int]       =		config_dict['qformer_config']

						if "model_type" in config_dict and hasattr(cls     ,  'model_type'					) and config_dict["model_type"] != cls.model_type:
							logger.warning(
							    F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
							    F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''					)

						return cls.from_dict(UpperCamelCase_     ,  **UpperCamelCase_					)






class 		lowerCamelCase__      (						A     ):




					'''simple docstring'''



					A_						    =						"""instructblip"""
					A_						    =						True




					def __init__(  self				:	Any     ,  UpperCamelCase_				:	List[Any]=None     ,  UpperCamelCase_				:	Tuple=None     ,  UpperCamelCase_				:	Dict=None     ,  UpperCamelCase_				:	Union[str, Any]=32     ,  **UpperCamelCase_				:	int					)  ->       List[str]:



						'''simple docstring'''





						super().__init__(**UpperCamelCase_					)

						if vision_config is None:
							_lowercase					:       Any       =		{}
							logger.info('vision_config is None. initializing the InstructBlipVisionConfig with default values.'					)

						if qformer_config is None:
							_lowercase					:       List[Any]       =		{}
							logger.info('qformer_config is None. Initializing the InstructBlipQFormerConfig with default values.'					)

						if text_config is None:
							_lowercase					:       List[Any]       =		{}
							logger.info('text_config is None. Initializing the text config with default values (`OPTConfig`).'					)

						_lowercase					:       List[Any]       =		InstructBlipVisionConfig(**UpperCamelCase_					)
						_lowercase					:       Union[str, Any]       =		InstructBlipQFormerConfig(**UpperCamelCase_					)
						_lowercase					:       Union[str, Any]       =		text_config['model_type'] if 'model_type' in text_config else 'opt'
						_lowercase					:       int       =		CONFIG_MAPPING[text_model_type](**UpperCamelCase_					)

						_lowercase					:       str       =		self.text_config.tie_word_embeddings
						_lowercase					:       int       =		self.text_config.is_encoder_decoder

						_lowercase					:       Tuple       =		num_query_tokens
						_lowercase					:       str       =		self.vision_config.hidden_size
						_lowercase					:       Union[str, Any]       =		self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
						_lowercase					:       List[Any]       =		1.0
						_lowercase					:       int       =		0.02




					@classmethod
					def 						__UpperCAmelCase     (  cls				:	Tuple     ,  UpperCamelCase_				:	InstructBlipVisionConfig     ,  UpperCamelCase_				:	InstructBlipQFormerConfig     ,  UpperCamelCase_				:	PretrainedConfig     ,  **UpperCamelCase_				:	Dict     ,  )  ->       List[str]:



						'''simple docstring'''





						return cls(
						    vision_config=vision_config.to_dict()     ,  qformer_config=qformer_config.to_dict()     ,  text_config=text_config.to_dict()     ,  **UpperCamelCase_     ,  )




					def 						__UpperCAmelCase     (  self				:	Dict					)  ->       List[str]:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		copy.deepcopy(self.__dict__					)
						_lowercase					:       Optional[int]       =		self.vision_config.to_dict()
						_lowercase					:       Optional[Any]       =		self.qformer_config.to_dict()
						_lowercase					:       Tuple       =		self.text_config.to_dict()
						_lowercase					:       Dict       =		self.__class__.model_type
						return output
