


"""simple docstring"""






import copy
from typing import Dict

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING
from ..bit import BitConfig


_lowerCamelCase  =	logging.get_logger(__name__)

_lowerCamelCase  =	{
    'google/vit-hybrid-base-bit-384': 'https://huggingface.co/vit-hybrid-base-bit-384/resolve/main/config.json',
    # See all ViT hybrid models at https://huggingface.co/models?filter=vit
}


class       lowerCamelCase_		(      lowercase ):





				"""simple docstring"""







				_lowerCAmelCase   :   Dict   				=       "vit-hybrid"



				def __init__(    self							,		UpperCAmelCase__=None							,		UpperCAmelCase__=768							,		UpperCAmelCase__=12							,		UpperCAmelCase__=12							,		UpperCAmelCase__=3072							,		UpperCAmelCase__="gelu"							,		UpperCAmelCase__=0.0							,		UpperCAmelCase__=0.0							,		UpperCAmelCase__=0.02							,		UpperCAmelCase__=1e-12							,		UpperCAmelCase__=224							,		UpperCAmelCase__=1							,		UpperCAmelCase__=3							,		UpperCAmelCase__=[1, 1024, 24, 24]							,		UpperCAmelCase__=True							,		**UpperCAmelCase__							,		):
								super().__init__(**UpperCAmelCase__  )

								if backbone_config is None:
												logger.info("`backbone_config` is `None`. Initializing the config with a `BiT` backbone."  )
												SCREAMING_SNAKE_CASE__  				=					{
												    "global_padding": "same",
												    "layer_type": "bottleneck",
												    "depths": [3, 4, 9],
												    "out_features": ["stage3"],
												    "embedding_dynamic_padding": True,
												}

								if isinstance(UpperCAmelCase__							,		UpperCAmelCase__  ):
												if "model_type" in backbone_config:
																SCREAMING_SNAKE_CASE__  				=					CONFIG_MAPPING[backbone_config["model_type"]]
												else:
																logger.info(
																    "`model_type` is not found in `backbone_config`. Use `Bit` as the backbone configuration class."  )
																SCREAMING_SNAKE_CASE__  				=					BitConfig
												SCREAMING_SNAKE_CASE__  				=					backbone_config_class(**UpperCAmelCase__  )

								SCREAMING_SNAKE_CASE__  				=					backbone_featmap_shape
								SCREAMING_SNAKE_CASE__  				=					backbone_config
								SCREAMING_SNAKE_CASE__  				=					hidden_size
								SCREAMING_SNAKE_CASE__  				=					num_hidden_layers
								SCREAMING_SNAKE_CASE__  				=					num_attention_heads
								SCREAMING_SNAKE_CASE__  				=					intermediate_size
								SCREAMING_SNAKE_CASE__  				=					hidden_act
								SCREAMING_SNAKE_CASE__  				=					hidden_dropout_prob
								SCREAMING_SNAKE_CASE__  				=					attention_probs_dropout_prob
								SCREAMING_SNAKE_CASE__  				=					initializer_range
								SCREAMING_SNAKE_CASE__  				=					layer_norm_eps
								SCREAMING_SNAKE_CASE__  				=					image_size
								SCREAMING_SNAKE_CASE__  				=					patch_size
								SCREAMING_SNAKE_CASE__  				=					num_channels
								SCREAMING_SNAKE_CASE__  				=					qkv_bias






				def 	lowerCAmelCase__		(    self  ):
								SCREAMING_SNAKE_CASE__  				=					copy.deepcopy(self.__dict__  )
								SCREAMING_SNAKE_CASE__  				=					self.backbone_config.to_dict()
								SCREAMING_SNAKE_CASE__  				=					self.__class__.model_type
								return output




"""simple docstring"""






class       lowerCamelCase_		:





				"""simple docstring"""







				class       lowerCamelCase_		:





								"""simple docstring"""







								_lowerCAmelCase   :   Dict   				=       "_prev", "_data", "_next"



								def __init__(    self							,		UpperCAmelCase__							,		UpperCAmelCase__							,		UpperCAmelCase__  ):
												SCREAMING_SNAKE_CASE__  				=					link_p
												SCREAMING_SNAKE_CASE__  				=					element
												SCREAMING_SNAKE_CASE__  				=					link_n






								def 	lowerCAmelCase__		(    self  ):
												return (
												    f''' Prev -> {self._prev is not None}, Next -> {self._next is not None}'''
												)



				def __init__(    self  ):
								SCREAMING_SNAKE_CASE__  				=					self._Node(UpperCAmelCase__							,		UpperCAmelCase__							,		UpperCAmelCase__  )
								SCREAMING_SNAKE_CASE__  				=					self._Node(UpperCAmelCase__							,		UpperCAmelCase__							,		UpperCAmelCase__  )
								SCREAMING_SNAKE_CASE__  				=					self._trailer
								SCREAMING_SNAKE_CASE__  				=					self._header
								SCREAMING_SNAKE_CASE__  				=					0



				def __len__(    self  ):
								return self._size



				def 	lowerCAmelCase__		(    self  ):
								return self.__len__() == 0



				def 	lowerCAmelCase__		(    self							,		UpperCAmelCase__							,		UpperCAmelCase__							,		UpperCAmelCase__  ):
								# Create new_node by setting it's prev.link -> header
								# setting it's next.link -> trailer
								SCREAMING_SNAKE_CASE__  				=					self._Node(UpperCAmelCase__							,		UpperCAmelCase__							,		UpperCAmelCase__  )
								SCREAMING_SNAKE_CASE__  				=					new_node
								SCREAMING_SNAKE_CASE__  				=					new_node
								self._size += 1
								return self






				def 	lowerCAmelCase__		(    self							,		UpperCAmelCase__  ):
								SCREAMING_SNAKE_CASE__  				=					node._prev
								SCREAMING_SNAKE_CASE__  				=					node._next

								SCREAMING_SNAKE_CASE__  				=					successor
								SCREAMING_SNAKE_CASE__  				=					predecessor
								self._size -= 1
								SCREAMING_SNAKE_CASE__  				=					node._data
								SCREAMING_SNAKE_CASE__  				=					SCREAMING_SNAKE_CASE__  				=					SCREAMING_SNAKE_CASE__  				=					None
								del node
								return temp


class       lowerCamelCase_		(      _DoublyLinkedBase ):





				"""simple docstring"""







				def 	lowerCAmelCase__		(    self  ):
								if self.is_empty():
												raise Exception("List is empty"  )
								return self._header._next._data



				def 	lowerCAmelCase__		(    self  ):
								if self.is_empty():
												raise Exception("List is empty"  )
								return self._trailer._prev._data



				def 	lowerCAmelCase__		(    self							,		UpperCAmelCase__  ):
								return self._insert(self._header							,		UpperCAmelCase__							,		self._header._next  )



				def 	lowerCAmelCase__		(    self							,		UpperCAmelCase__  ):
								return self._insert(self._trailer._prev							,		UpperCAmelCase__							,		self._trailer  )



				def 	lowerCAmelCase__		(    self  ):
								if self.is_empty():
												raise IndexError("remove_first from empty list"  )
								return self._delete(self._header._next  )






				def 	lowerCAmelCase__		(    self  ):
								if self.is_empty():
												raise IndexError("remove_first from empty list"  )
								return self._delete(self._trailer._prev  )
