






"""simple docstring"""



import inspect
import unittest

from transformers import SegformerConfig, is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
						import torch

						from transformers import (
						    MODEL_MAPPING,
						    SegformerForImageClassification,
						    SegformerForSemanticSegmentation,
						    SegformerModel,
						)
						from transformers.models.segformer.modeling_segformer import SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
						from PIL import Image

						from transformers import SegformerImageProcessor







class   lowercase__     (				__SCREAMING_SNAKE_CASE  ):


			def       UpperCAmelCase__		( self	:    int   ):
										lowerCamelCase_			:				str										=self.config_class(**self.inputs_dict   )
										self.parent.assertTrue(hasattr(_SCREAMING_SNAKE_CASE  ,			"hidden_sizes"   )   )
										self.parent.assertTrue(hasattr(_SCREAMING_SNAKE_CASE  ,			"num_attention_heads"   )   )
										self.parent.assertTrue(hasattr(_SCREAMING_SNAKE_CASE  ,			"num_encoder_blocks"   )   )







class   lowercase__     :


			def __init__( self	:    Union[str, Any]  ,			snake_case__	:    List[str]  ,			snake_case__	:    Optional[Any]=13  ,			snake_case__	:    Optional[int]=64  ,			snake_case__	:    Union[str, Any]=3  ,			snake_case__	:    Tuple=4  ,			snake_case__	:    Union[str, Any]=[2, 2, 2, 2]  ,			snake_case__	:    Optional[int]=[8, 4, 2, 1]  ,			snake_case__	:    Optional[Any]=[16, 32, 64, 128]  ,			snake_case__	:    Optional[int]=[1, 4, 8, 16]  ,			snake_case__	:    Optional[Any]=[1, 2, 4, 8]  ,			snake_case__	:    List[Any]=True  ,			snake_case__	:    Dict=True  ,			snake_case__	:    Optional[int]="gelu"  ,			snake_case__	:    Dict=0.1  ,			snake_case__	:    str=0.1  ,			snake_case__	:    Any=0.02  ,			snake_case__	:    Any=3  ,			snake_case__	:    Dict=None  ,			):
										lowerCamelCase_			:				Tuple										=parent
										lowerCamelCase_			:				Optional[int]										=batch_size
										lowerCamelCase_			:				Dict										=image_size
										lowerCamelCase_			:				List[str]										=num_channels
										lowerCamelCase_			:				List[Any]										=num_encoder_blocks
										lowerCamelCase_			:				Any										=sr_ratios
										lowerCamelCase_			:				int										=depths
										lowerCamelCase_			:				str										=hidden_sizes
										lowerCamelCase_			:				List[Any]										=downsampling_rates
										lowerCamelCase_			:				int										=num_attention_heads
										lowerCamelCase_			:				Union[str, Any]										=is_training
										lowerCamelCase_			:				Optional[Any]										=use_labels
										lowerCamelCase_			:				Optional[Any]										=hidden_act
										lowerCamelCase_			:				int										=hidden_dropout_prob
										lowerCamelCase_			:				List[str]										=attention_probs_dropout_prob
										lowerCamelCase_			:				int										=initializer_range
										lowerCamelCase_			:				Union[str, Any]										=num_labels
										lowerCamelCase_			:				str										=scope


			def       UpperCAmelCase__		( self	:    Optional[Any]   ):
										lowerCamelCase_			:				Tuple										=floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]   )

										lowerCamelCase_			:				List[Any]										=None
										if self.use_labels:
																	lowerCamelCase_			:				str										=ids_tensor([self.batch_size, self.image_size, self.image_size]  ,			self.num_labels   )

										lowerCamelCase_			:				Any										=self.get_config()
										return config, pixel_values, labels


			def       UpperCAmelCase__		( self	:    Dict   ):
										return SegformerConfig(
										    image_size=self.image_size  ,			num_channels=self.num_channels  ,			num_encoder_blocks=self.num_encoder_blocks  ,			depths=self.depths  ,			hidden_sizes=self.hidden_sizes  ,			num_attention_heads=self.num_attention_heads  ,			hidden_act=self.hidden_act  ,			hidden_dropout_prob=self.hidden_dropout_prob  ,			attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,			initializer_range=self.initializer_range  ,			)


			def       UpperCAmelCase__		( self	:    str  ,			snake_case__	:    List[str]  ,			snake_case__	:    Any  ,			snake_case__	:    Dict   ):
										lowerCamelCase_			:				List[Any]										=SegformerModel(config=_SCREAMING_SNAKE_CASE   )
										model.to(_SCREAMING_SNAKE_CASE   )
										model.eval()
										lowerCamelCase_			:				int										=model(_SCREAMING_SNAKE_CASE   )
										lowerCamelCase_			:				Dict										=self.image_size // (self.downsampling_rates[-1] * 2)
										self.parent.assertEqual(
										    result.last_hidden_state.shape  ,			(self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)   )


			def       UpperCAmelCase__		( self	:    Union[str, Any]  ,			snake_case__	:    List[Any]  ,			snake_case__	:    Dict  ,			snake_case__	:    Optional[Any]   ):
										lowerCamelCase_			:				Tuple										=self.num_labels
										lowerCamelCase_			:				Optional[int]										=SegformerForSemanticSegmentation(_SCREAMING_SNAKE_CASE   )
										model.to(_SCREAMING_SNAKE_CASE   )
										model.eval()
										lowerCamelCase_			:				int										=model(_SCREAMING_SNAKE_CASE   )
										self.parent.assertEqual(
										    result.logits.shape  ,			(self.batch_size, self.num_labels, self.image_size // 4, self.image_size // 4)   )
										lowerCamelCase_			:				Union[str, Any]										=model(_SCREAMING_SNAKE_CASE  ,			labels=_SCREAMING_SNAKE_CASE   )
										self.parent.assertEqual(
										    result.logits.shape  ,			(self.batch_size, self.num_labels, self.image_size // 4, self.image_size // 4)   )
										self.parent.assertGreater(result.loss  ,			0.0   )


			def       UpperCAmelCase__		( self	:    Optional[int]  ,			snake_case__	:    str  ,			snake_case__	:    Dict  ,			snake_case__	:    Optional[int]   ):
										lowerCamelCase_			:				int										=1
										lowerCamelCase_			:				Any										=SegformerForSemanticSegmentation(config=_SCREAMING_SNAKE_CASE   )
										model.to(_SCREAMING_SNAKE_CASE   )
										model.eval()
										lowerCamelCase_			:				List[str]										=torch.randint(0  ,			1  ,			(self.batch_size, self.image_size, self.image_size)   ).to(_SCREAMING_SNAKE_CASE   )
										lowerCamelCase_			:				Any										=model(_SCREAMING_SNAKE_CASE  ,			labels=_SCREAMING_SNAKE_CASE   )
										self.parent.assertGreater(result.loss  ,			0.0   )


			def       UpperCAmelCase__		( self	:    Tuple   ):
										lowerCamelCase_			:				Tuple										=self.prepare_config_and_inputs()
										lowerCamelCase_			:				List[Any]										=config_and_inputs
										lowerCamelCase_			:				Optional[Any]										={"pixel_values": pixel_values}
										return config, inputs_dict







@require_torch
class   lowercase__     (				__SCREAMING_SNAKE_CASE,  __SCREAMING_SNAKE_CASE,  unittest.TestCase  ):
			_UpperCAmelCase						:Tuple       =					(
			    (
			        SegformerModel,
			        SegformerForSemanticSegmentation,
			        SegformerForImageClassification,
			    )
			    if is_torch_available()
			    else ()
			)
			_UpperCAmelCase						:Tuple       =					(
			    {
			        "feature-extraction": SegformerModel,
			        "image-classification": SegformerForImageClassification,
			        "image-segmentation": SegformerForSemanticSegmentation,
			    }
			    if is_torch_available()
			    else {}
			)

			_UpperCAmelCase						:Any       =					True
			_UpperCAmelCase						:List[str]       =					False
			_UpperCAmelCase						:List[str]       =					False
			_UpperCAmelCase						:List[str]       =					False


			def       UpperCAmelCase__		( self	:    Dict   ):
										lowerCamelCase_			:				List[str]										=SegformerModelTester(self   )
										lowerCamelCase_			:				str										=SegformerConfigTester(self  ,			config_class=_SCREAMING_SNAKE_CASE   )


			def       UpperCAmelCase__		( self	:    Tuple   ):
										self.config_tester.run_common_tests()


			def       UpperCAmelCase__		( self	:    Any   ):
										lowerCamelCase_			:				str										=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE   )


			def       UpperCAmelCase__		( self	:    int   ):
										lowerCamelCase_			:				Any										=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_binary_image_segmentation(*_SCREAMING_SNAKE_CASE   )


			def       UpperCAmelCase__		( self	:    List[str]   ):
										lowerCamelCase_			:				Union[str, Any]										=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_image_segmentation(*_SCREAMING_SNAKE_CASE   )


			@unittest.skip("SegFormer does not use inputs_embeds"   )
			def       UpperCAmelCase__		( self	:    List[str]   ):
										pass


			@unittest.skip("SegFormer does not have get_input_embeddings method and get_output_embeddings methods"   )
			def       UpperCAmelCase__		( self	:    Union[str, Any]   ):
										pass


			def       UpperCAmelCase__		( self	:    List[str]   ):
										lowerCamelCase_			:				str										=self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
																	lowerCamelCase_			:				Any										=model_class(_SCREAMING_SNAKE_CASE   )
																	lowerCamelCase_			:				List[str]										=inspect.signature(model.forward   )
																	# signature.parameters is an OrderedDict => so arg_names order is deterministic
																	lowerCamelCase_			:				Any										=[*signature.parameters.keys()]

																	lowerCamelCase_			:				Tuple										=["pixel_values"]
																	self.assertListEqual(arg_names[:1]  ,			_SCREAMING_SNAKE_CASE   )


			def       UpperCAmelCase__		( self	:    Optional[int]   ):
										lowerCamelCase_			:				int										=self.model_tester.prepare_config_and_inputs_for_common()
										lowerCamelCase_			:				Dict										=True

										for model_class in self.all_model_classes:
																	lowerCamelCase_			:				Tuple										=True
																	lowerCamelCase_			:				Any										=False
																	lowerCamelCase_			:				int										=True
																	lowerCamelCase_			:				Any										=model_class(_SCREAMING_SNAKE_CASE   )
																	model.to(_SCREAMING_SNAKE_CASE   )
																	model.eval()
																	with torch.no_grad():
																								lowerCamelCase_			:				Dict										=model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE   )   )
																	lowerCamelCase_			:				Optional[int]										=outputs.attentions

																	lowerCamelCase_			:				Union[str, Any]										=sum(self.model_tester.depths   )
																	self.assertEqual(len(_SCREAMING_SNAKE_CASE   )  ,			_SCREAMING_SNAKE_CASE   )

																	# check that output_attentions also work using config
																	del inputs_dict["output_attentions"]
																	lowerCamelCase_			:				int										=True
																	lowerCamelCase_			:				int										=model_class(_SCREAMING_SNAKE_CASE   )
																	model.to(_SCREAMING_SNAKE_CASE   )
																	model.eval()
																	with torch.no_grad():
																								lowerCamelCase_			:				Optional[Any]										=model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE   )   )
																	lowerCamelCase_			:				Optional[int]										=outputs.attentions

																	self.assertEqual(len(_SCREAMING_SNAKE_CASE   )  ,			_SCREAMING_SNAKE_CASE   )

																	# verify the first attentions (first block, first layer)
																	lowerCamelCase_			:				Optional[int]										=(self.model_tester.image_size // 4) ** 2
																	lowerCamelCase_			:				Dict										=(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
																	self.assertListEqual(
																	    list(attentions[0].shape[-3:]   )  ,			[self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]  ,			)

																	# verify the last attentions (last block, last layer)
																	lowerCamelCase_			:				Tuple										=(self.model_tester.image_size // 32) ** 2
																	lowerCamelCase_			:				List[Any]										=(self.model_tester.image_size // (32 * self.model_tester.sr_ratios[-1])) ** 2
																	self.assertListEqual(
																	    list(attentions[-1].shape[-3:]   )  ,			[self.model_tester.num_attention_heads[-1], expected_seq_len, expected_reduced_seq_len]  ,			)
																	lowerCamelCase_			:				List[str]										=len(_SCREAMING_SNAKE_CASE   )

																	# Check attention is always last and order is fine
																	lowerCamelCase_			:				List[str]										=True
																	lowerCamelCase_			:				Optional[int]										=True
																	lowerCamelCase_			:				int										=model_class(_SCREAMING_SNAKE_CASE   )
																	model.to(_SCREAMING_SNAKE_CASE   )
																	model.eval()
																	with torch.no_grad():
																								lowerCamelCase_			:				List[Any]										=model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE   )   )

																	self.assertEqual(out_len + 1  ,			len(_SCREAMING_SNAKE_CASE   )   )

																	lowerCamelCase_			:				Optional[int]										=outputs.attentions

																	self.assertEqual(len(_SCREAMING_SNAKE_CASE   )  ,			_SCREAMING_SNAKE_CASE   )
																	# verify the first attentions (first block, first layer)
																	lowerCamelCase_			:				Dict										=(self.model_tester.image_size // 4) ** 2
																	lowerCamelCase_			:				Any										=(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
																	self.assertListEqual(
																	    list(self_attentions[0].shape[-3:]   )  ,			[self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]  ,			)


			def       UpperCAmelCase__		( self	:    Optional[int]   ):

										def check_hidden_states_output(snake_case__	:    Union[str, Any]  ,			snake_case__	:    Dict  ,			snake_case__	:    List[str]   ):
																	lowerCamelCase_			:				int										=model_class(_SCREAMING_SNAKE_CASE   )
																	model.to(_SCREAMING_SNAKE_CASE   )
																	model.eval()

																	with torch.no_grad():
																								lowerCamelCase_			:				Tuple										=model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE   )   )

																	lowerCamelCase_			:				Tuple										=outputs.hidden_states

																	lowerCamelCase_			:				Union[str, Any]										=self.model_tester.num_encoder_blocks
																	self.assertEqual(len(_SCREAMING_SNAKE_CASE   )  ,			_SCREAMING_SNAKE_CASE   )

																	# verify the first hidden states (first block)
																	self.assertListEqual(
																	    list(hidden_states[0].shape[-3:]   )  ,			[
																	        self.model_tester.hidden_sizes[0],
																	        self.model_tester.image_size // 4,
																	        self.model_tester.image_size // 4,
																	    ]  ,			)

										lowerCamelCase_			:				Union[str, Any]										=self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
																	lowerCamelCase_			:				List[Any]										=True
																	check_hidden_states_output(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE   )

																	# check that output_hidden_states also work using config
																	del inputs_dict["output_hidden_states"]
																	lowerCamelCase_			:				Any										=True

																	check_hidden_states_output(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE   )


			def       UpperCAmelCase__		( self	:    Any   ):

										if not self.model_tester.is_training:
																	return

										lowerCamelCase_			:				List[Any]										=self.model_tester.prepare_config_and_inputs_for_common()
										lowerCamelCase_			:				Any										=True

										for model_class in self.all_model_classes:
																	if model_class in get_values(_SCREAMING_SNAKE_CASE   ):
																								continue

																	lowerCamelCase_			:				List[Any]										=model_class(_SCREAMING_SNAKE_CASE   )
																	model.to(_SCREAMING_SNAKE_CASE   )
																	model.train()
																	lowerCamelCase_			:				Union[str, Any]										=self._prepare_for_class(_SCREAMING_SNAKE_CASE  ,			_SCREAMING_SNAKE_CASE  ,			return_labels=_SCREAMING_SNAKE_CASE   )
																	lowerCamelCase_			:				List[Any]										=model(**_SCREAMING_SNAKE_CASE   ).loss
																	loss.backward()


			@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."   )
			def       UpperCAmelCase__		( self	:    Any   ):
										pass


			@slow
			def       UpperCAmelCase__		( self	:    Optional[int]   ):

										for model_name in SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	lowerCamelCase_			:				Dict										=SegformerModel.from_pretrained(_SCREAMING_SNAKE_CASE   )
																	self.assertIsNotNone(_SCREAMING_SNAKE_CASE   )


def 					_snake_case							(	)							->      List[Any]:
							lowerCamelCase_			:				str										=Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"    )
							return image







@require_torch
class   lowercase__     (				unittest.TestCase  ):


			@slow
			def       UpperCAmelCase__		( self	:    List[Any]   ):
										lowerCamelCase_			:				List[Any]										=SegformerImageProcessor(
										    image_scale=(512, 512)  ,			keep_ratio=_SCREAMING_SNAKE_CASE  ,			align=_SCREAMING_SNAKE_CASE  ,			do_random_crop=_SCREAMING_SNAKE_CASE   )
										lowerCamelCase_			:				Any										=SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b0-finetuned-ade-512-512"   ).to(
										    _SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Any										=prepare_img()
										lowerCamelCase_			:				Any										=image_processor(images=_SCREAMING_SNAKE_CASE  ,			return_tensors="pt"   )
										lowerCamelCase_			:				Any										=encoded_inputs.pixel_values.to(_SCREAMING_SNAKE_CASE   )

										with torch.no_grad():
																	lowerCamelCase_			:				Dict										=model(_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Optional[Any]										=torch.Size((1, model.config.num_labels, 128, 128)   )
										self.assertEqual(outputs.logits.shape  ,			_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Any										=torch.tensor(
										    [
										        [[-4.6_310, -5.5_232, -6.2_356], [-5.1_921, -6.1_444, -6.5_996], [-5.4_424, -6.2_790, -6.7_574]],
										        [[-12.1_391, -13.3_122, -13.9_554], [-12.8_732, -13.9_352, -14.3_563], [-12.9_438, -13.8_226, -14.2_513]],
										        [[-12.5_134, -13.4_686, -14.4_915], [-12.8_669, -14.4_343, -14.7_758], [-13.2_523, -14.5_819, -15.0_694]],
										    ]   ).to(_SCREAMING_SNAKE_CASE   )
										self.assertTrue(torch.allclose(outputs.logits[0, :3, :3, :3]  ,			_SCREAMING_SNAKE_CASE  ,			atol=1E-4   )   )


			@slow
			def       UpperCAmelCase__		( self	:    int   ):
										lowerCamelCase_			:				int										=SegformerImageProcessor(
										    image_scale=(512, 512)  ,			keep_ratio=_SCREAMING_SNAKE_CASE  ,			align=_SCREAMING_SNAKE_CASE  ,			do_random_crop=_SCREAMING_SNAKE_CASE   )
										lowerCamelCase_			:				Dict										=SegformerForSemanticSegmentation.from_pretrained(
										    "nvidia/segformer-b1-finetuned-cityscapes-1024-1024"   ).to(_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Union[str, Any]										=prepare_img()
										lowerCamelCase_			:				Optional[Any]										=image_processor(images=_SCREAMING_SNAKE_CASE  ,			return_tensors="pt"   )
										lowerCamelCase_			:				Tuple										=encoded_inputs.pixel_values.to(_SCREAMING_SNAKE_CASE   )

										with torch.no_grad():
																	lowerCamelCase_			:				Any										=model(_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Optional[int]										=torch.Size((1, model.config.num_labels, 128, 128)   )
										self.assertEqual(outputs.logits.shape  ,			_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Union[str, Any]										=torch.tensor(
										    [
										        [[-13.5_748, -13.9_111, -12.6_500], [-14.3_500, -15.3_683, -14.2_328], [-14.7_532, -16.0_424, -15.6_087]],
										        [[-17.1_651, -15.8_725, -12.9_653], [-17.2_580, -17.3_718, -14.8_223], [-16.6_058, -16.8_783, -16.7_452]],
										        [[-3.6_456, -3.0_209, -1.4_203], [-3.0_797, -3.1_959, -2.0_000], [-1.8_757, -1.9_217, -1.6_997]],
										    ]   ).to(_SCREAMING_SNAKE_CASE   )
										self.assertTrue(torch.allclose(outputs.logits[0, :3, :3, :3]  ,			_SCREAMING_SNAKE_CASE  ,			atol=1E-1   )   )


			@slow
			def       UpperCAmelCase__		( self	:    int   ):
										lowerCamelCase_			:				List[Any]										=SegformerImageProcessor(
										    image_scale=(512, 512)  ,			keep_ratio=_SCREAMING_SNAKE_CASE  ,			align=_SCREAMING_SNAKE_CASE  ,			do_random_crop=_SCREAMING_SNAKE_CASE   )
										lowerCamelCase_			:				List[str]										=SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b0-finetuned-ade-512-512"   ).to(
										    _SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Any										=prepare_img()
										lowerCamelCase_			:				Dict										=image_processor(images=_SCREAMING_SNAKE_CASE  ,			return_tensors="pt"   )
										lowerCamelCase_			:				List[str]										=encoded_inputs.pixel_values.to(_SCREAMING_SNAKE_CASE   )

										with torch.no_grad():
																	lowerCamelCase_			:				int										=model(_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				Tuple										=outputs.logits.detach().cpu()

										lowerCamelCase_			:				Any										=image_processor.post_process_semantic_segmentation(outputs=_SCREAMING_SNAKE_CASE  ,			target_sizes=[(500, 300)]   )
										lowerCamelCase_			:				Union[str, Any]										=torch.Size((500, 300)   )
										self.assertEqual(segmentation[0].shape  ,			_SCREAMING_SNAKE_CASE   )

										lowerCamelCase_			:				List[Any]										=image_processor.post_process_semantic_segmentation(outputs=_SCREAMING_SNAKE_CASE   )
										lowerCamelCase_			:				Union[str, Any]										=torch.Size((128, 128)   )
										self.assertEqual(segmentation[0].shape  ,			_SCREAMING_SNAKE_CASE   )








"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


__snake_case				:  Dict =       logging.get_logger(__name__)

__snake_case				:  int =       {
    'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json',
    'uclanlp/visualbert-vqa-pre': 'https://huggingface.co/uclanlp/visualbert-vqa-pre/resolve/main/config.json',
    'uclanlp/visualbert-vqa-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-vqa-coco-pre/resolve/main/config.json'
    ),
    'uclanlp/visualbert-vcr': 'https://huggingface.co/uclanlp/visualbert-vcr/resolve/main/config.json',
    'uclanlp/visualbert-vcr-pre': 'https://huggingface.co/uclanlp/visualbert-vcr-pre/resolve/main/config.json',
    'uclanlp/visualbert-vcr-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-vcr-coco-pre/resolve/main/config.json'
    ),
    'uclanlp/visualbert-nlvr2': 'https://huggingface.co/uclanlp/visualbert-nlvr2/resolve/main/config.json',
    'uclanlp/visualbert-nlvr2-pre': 'https://huggingface.co/uclanlp/visualbert-nlvr2-pre/resolve/main/config.json',
    'uclanlp/visualbert-nlvr2-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-nlvr2-coco-pre/resolve/main/config.json'
    )
    # See all VisualBERT models at https://huggingface.co/models?filter=visual_bert
}



class      A__  (    __SCREAMING_SNAKE_CASE				):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE        =      'visual_bert'

	def __init__(	self:						int			,     _SCREAMING_SNAKE_CASE:						Dict=3_0522			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=768			,     _SCREAMING_SNAKE_CASE:						List[str]=512			,     _SCREAMING_SNAKE_CASE:						Optional[int]=12			,     _SCREAMING_SNAKE_CASE:						List[str]=12			,     _SCREAMING_SNAKE_CASE:						Tuple=3072			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]="gelu"			,     _SCREAMING_SNAKE_CASE:						Tuple=0.1			,     _SCREAMING_SNAKE_CASE:						str=0.1			,     _SCREAMING_SNAKE_CASE:						List[Any]=512			,     _SCREAMING_SNAKE_CASE:						Any=2			,     _SCREAMING_SNAKE_CASE:						Optional[int]=0.02			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=1e-12			,     _SCREAMING_SNAKE_CASE:						List[str]=False			,     _SCREAMING_SNAKE_CASE:						int=True			,     _SCREAMING_SNAKE_CASE:						str=1			,     _SCREAMING_SNAKE_CASE:						Tuple=0			,     _SCREAMING_SNAKE_CASE:						Any=2			,     **_SCREAMING_SNAKE_CASE:						List[str]			,     )							->			str:

				"""simple docstring"""

				super().__init__(pad_token_id=_SCREAMING_SNAKE_CASE			,     bos_token_id=_SCREAMING_SNAKE_CASE			,     eos_token_id=_SCREAMING_SNAKE_CASE			,     **_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase :    str				=			vocab_size
				__lowerCAmelCase :    Tuple				=			max_position_embeddings
				__lowerCAmelCase :    Any				=			hidden_size
				__lowerCAmelCase :    Union[str, Any]				=			visual_embedding_dim
				__lowerCAmelCase :    List[str]				=			num_hidden_layers
				__lowerCAmelCase :    Optional[int]				=			num_attention_heads
				__lowerCAmelCase :    str				=			intermediate_size
				__lowerCAmelCase :    int				=			hidden_act
				__lowerCAmelCase :    Union[str, Any]				=			hidden_dropout_prob
				__lowerCAmelCase :    int				=			attention_probs_dropout_prob
				__lowerCAmelCase :    List[Any]				=			initializer_range
				__lowerCAmelCase :    Dict				=			type_vocab_size
				__lowerCAmelCase :    Optional[int]				=			layer_norm_eps
				__lowerCAmelCase :    Union[str, Any]				=			bypass_transformer
				__lowerCAmelCase :    List[str]				=			special_visual_initialize