



'''simple docstring'''



from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowerCAmelCase	:		Dict				=   logging.get_logger(__name__)

lowerCAmelCase	:		Optional[int]				=   {
    '''shi-labs/dinat-mini-in1k-224''': '''https://huggingface.co/shi-labs/dinat-mini-in1k-224/resolve/main/config.json''',
    # See all Dinat models at https://huggingface.co/models?filter=dinat
}






class 					UpperCAmelCase__	(		UpperCamelCase__							,       UpperCamelCase__ ):
					a      :     List[Any]        =							"""dinat"""

					a      :     Dict        =							{
					    """num_attention_heads""": """num_heads""",
					    """num_hidden_layers""": """num_layers""",
					}



					def __init__(    self			,				UpperCamelCase=4			,				UpperCamelCase=3			,				UpperCamelCase=64			,				UpperCamelCase=[3, 4, 6, 5]			,				UpperCamelCase=[2, 4, 8, 16]			,				UpperCamelCase=7			,				UpperCamelCase=[[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]			,				UpperCamelCase=3.0			,				UpperCamelCase=True			,				UpperCamelCase=0.0			,				UpperCamelCase=0.0			,				UpperCamelCase=0.1			,				UpperCamelCase="gelu"			,				UpperCamelCase=0.02			,				UpperCamelCase=1E-5			,				UpperCamelCase=0.0			,				UpperCamelCase=None			,				UpperCamelCase=None			,				**UpperCamelCase			,				)     ->			List[str]:
						super().__init__(**UpperCamelCase     )

						__lowerCAmelCase												=  patch_size
						__lowerCAmelCase												=  num_channels
						__lowerCAmelCase												=  embed_dim
						__lowerCAmelCase												=  depths
						__lowerCAmelCase												=  len(UpperCamelCase     )
						__lowerCAmelCase												=  num_heads
						__lowerCAmelCase												=  kernel_size
						__lowerCAmelCase												=  dilations
						__lowerCAmelCase												=  mlp_ratio
						__lowerCAmelCase												=  qkv_bias
						__lowerCAmelCase												=  hidden_dropout_prob
						__lowerCAmelCase												=  attention_probs_dropout_prob
						__lowerCAmelCase												=  drop_path_rate
						__lowerCAmelCase												=  hidden_act
						__lowerCAmelCase												=  layer_norm_eps
						__lowerCAmelCase												=  initializer_range
						# we set the hidden_size attribute in order to make Dinat work with VisionEncoderDecoderModel
						# this indicates the channel dimension after the last stage of the model
						__lowerCAmelCase												=  int(embed_dim * 2 ** (len(UpperCamelCase     ) - 1)     )
						__lowerCAmelCase												=  layer_scale_init_value
						__lowerCAmelCase												=  ["stem"] + [F'''stage{idx}''' for idx in range(1			,				len(UpperCamelCase     ) + 1     )]
						__lowerCAmelCase							,       __lowerCAmelCase												=  get_aligned_output_features_output_indices(
						    out_features=UpperCamelCase			,				out_indices=UpperCamelCase			,				stage_names=self.stage_names     )




'''simple docstring'''



import os
import sys
import unittest


lowerCAmelCase	:		str				=   os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, '''utils'''))

import get_test_info  # noqa: E402
from get_test_info import (  # noqa: E402
    get_model_to_test_mapping,
    get_model_to_tester_mapping,
    get_test_to_tester_mapping,
)


lowerCAmelCase	:		Tuple				=   os.path.join('''tests''', '''models''', '''bert''', '''test_modeling_bert.py''')
lowerCAmelCase	:		Tuple				=   os.path.join('''tests''', '''models''', '''blip''', '''test_modeling_blip.py''')






class 					UpperCAmelCase__	(		unittest.TestCase ):



					def        UpperCAmelCase_ (    self     )     ->			str:
						__lowerCAmelCase												=  get_test_to_tester_mapping(UpperCamelCase     )
						__lowerCAmelCase												=  get_test_to_tester_mapping(UpperCamelCase     )

						__lowerCAmelCase												=  {"BertModelTest": "BertModelTester"}

						__lowerCAmelCase												=  {
						    "BlipModelTest": "BlipModelTester",
						    "BlipTextImageModelTest": "BlipTextImageModelsModelTester",
						    "BlipTextModelTest": "BlipTextModelTester",
						    "BlipTextRetrievalModelTest": "BlipTextRetrievalModelTester",
						    "BlipVQAModelTest": "BlipVQAModelTester",
						    "BlipVisionModelTest": "BlipVisionModelTester",
						}

						self.assertEqual(get_test_info.to_json(UpperCamelCase     )			,				UpperCamelCase     )
						self.assertEqual(get_test_info.to_json(UpperCamelCase     )			,				UpperCamelCase     )



					def        UpperCAmelCase_ (    self     )     ->			List[Any]:
						__lowerCAmelCase												=  get_model_to_test_mapping(UpperCamelCase     )
						__lowerCAmelCase												=  get_model_to_test_mapping(UpperCamelCase     )

						__lowerCAmelCase												=  {
						    "BertForMaskedLM": ["BertModelTest"],
						    "BertForMultipleChoice": ["BertModelTest"],
						    "BertForNextSentencePrediction": ["BertModelTest"],
						    "BertForPreTraining": ["BertModelTest"],
						    "BertForQuestionAnswering": ["BertModelTest"],
						    "BertForSequenceClassification": ["BertModelTest"],
						    "BertForTokenClassification": ["BertModelTest"],
						    "BertLMHeadModel": ["BertModelTest"],
						    "BertModel": ["BertModelTest"],
						}

						__lowerCAmelCase												=  {
						    "BlipForConditionalGeneration": ["BlipTextImageModelTest"],
						    "BlipForImageTextRetrieval": ["BlipTextRetrievalModelTest"],
						    "BlipForQuestionAnswering": ["BlipVQAModelTest"],
						    "BlipModel": ["BlipModelTest"],
						    "BlipTextModel": ["BlipTextModelTest"],
						    "BlipVisionModel": ["BlipVisionModelTest"],
						}

						self.assertEqual(get_test_info.to_json(UpperCamelCase     )			,				UpperCamelCase     )
						self.assertEqual(get_test_info.to_json(UpperCamelCase     )			,				UpperCamelCase     )



					def        UpperCAmelCase_ (    self     )     ->			str:
						__lowerCAmelCase												=  get_model_to_tester_mapping(UpperCamelCase     )
						__lowerCAmelCase												=  get_model_to_tester_mapping(UpperCamelCase     )

						__lowerCAmelCase												=  {
						    "BertForMaskedLM": ["BertModelTester"],
						    "BertForMultipleChoice": ["BertModelTester"],
						    "BertForNextSentencePrediction": ["BertModelTester"],
						    "BertForPreTraining": ["BertModelTester"],
						    "BertForQuestionAnswering": ["BertModelTester"],
						    "BertForSequenceClassification": ["BertModelTester"],
						    "BertForTokenClassification": ["BertModelTester"],
						    "BertLMHeadModel": ["BertModelTester"],
						    "BertModel": ["BertModelTester"],
						}

						__lowerCAmelCase												=  {
						    "BlipForConditionalGeneration": ["BlipTextImageModelsModelTester"],
						    "BlipForImageTextRetrieval": ["BlipTextRetrievalModelTester"],
						    "BlipForQuestionAnswering": ["BlipVQAModelTester"],
						    "BlipModel": ["BlipModelTester"],
						    "BlipTextModel": ["BlipTextModelTester"],
						    "BlipVisionModel": ["BlipVisionModelTester"],
						}

						self.assertEqual(get_test_info.to_json(UpperCamelCase     )			,				UpperCamelCase     )
						self.assertEqual(get_test_info.to_json(UpperCamelCase     )			,				UpperCamelCase     )