




"""simple docstring"""





from collections import OrderedDict
from typing import Mapping

from packaging import version

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


_lowercase		 =      logging.get_logger(__name__)

_lowercase		 =      {
    """facebook/convnext-tiny-224""": """https://huggingface.co/facebook/convnext-tiny-224/resolve/main/config.json""",
    # See all ConvNeXT models at https://huggingface.co/models?filter=convnext
}

class  __lowercase    (     snake_case_  ,				snake_case_		):


				'''simple docstring'''


				_lowerCAmelCase		     ="convnext"

				def __init__(				self				:       Tuple ,SCREAMING_SNAKE_CASE_				:       List[Any]=3 ,SCREAMING_SNAKE_CASE_				:       Optional[int]=4 ,SCREAMING_SNAKE_CASE_				:       Dict=4 ,SCREAMING_SNAKE_CASE_				:       Dict=None ,SCREAMING_SNAKE_CASE_				:       List[str]=None ,SCREAMING_SNAKE_CASE_				:       Any="gelu" ,SCREAMING_SNAKE_CASE_				:       Optional[Any]=0.02 ,SCREAMING_SNAKE_CASE_				:       List[Any]=1E-12 ,SCREAMING_SNAKE_CASE_				:       Any=1E-6 ,SCREAMING_SNAKE_CASE_				:       Tuple=0.0 ,SCREAMING_SNAKE_CASE_				:       Tuple=2_2_4 ,SCREAMING_SNAKE_CASE_				:       Optional[int]=None ,SCREAMING_SNAKE_CASE_				:       List[Any]=None ,**SCREAMING_SNAKE_CASE_				:       Any ,):
										super().__init__(**SCREAMING_SNAKE_CASE_ )

										snake_case__    :   Union[str, Any]							     =   num_channels
										snake_case__    :   Optional[int]							     =   patch_size
										snake_case__    :   Any							     =   num_stages
										snake_case__    :   Optional[int]							     =   [9_6, 1_9_2, 3_8_4, 7_6_8] if hidden_sizes is None else hidden_sizes
										snake_case__    :   Any							     =   [3, 3, 9, 3] if depths is None else depths
										snake_case__    :   Optional[int]							     =   hidden_act
										snake_case__    :   Union[str, Any]							     =   initializer_range
										snake_case__    :   Optional[int]							     =   layer_norm_eps
										snake_case__    :   Any							     =   layer_scale_init_value
										snake_case__    :   int							     =   drop_path_rate
										snake_case__    :   Dict							     =   image_size
										snake_case__    :   Optional[int]							     =   ['''stem'''] + [F'''stage{idx}''' for idx in range(1 ,len(self.depths ) + 1 )]
										snake_case__     ,		snake_case__    :   Optional[Any]							     =   get_aligned_output_features_output_indices(
										    out_features=SCREAMING_SNAKE_CASE_ ,out_indices=SCREAMING_SNAKE_CASE_ ,stage_names=self.stage_names )







class  __lowercase    (     snake_case_		):


				'''simple docstring'''


				_lowerCAmelCase		     =version.parse("1.11"		)

				@property
				def  _lowerCamelCase   (				self				:       Dict ):
										return OrderedDict(
										    [
										        ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
										    ] )





				@property
				def  _lowerCamelCase   (				self				:       str ):
										return 1E-5








"""simple docstring"""





class  __lowercase    :


				'''simple docstring'''


				class  __lowercase    :


								'''simple docstring'''


								_lowerCAmelCase		     ="_prev", "_data", "_next"

								def __init__(				self				:       List[Any] ,SCREAMING_SNAKE_CASE_				:       int ,SCREAMING_SNAKE_CASE_				:       Union[str, Any] ,SCREAMING_SNAKE_CASE_				:       Any ):
														snake_case__    :   Any							     =   link_p
														snake_case__    :   List[str]							     =   element
														snake_case__    :   str							     =   link_n





								def  _lowerCamelCase   (				self				:       Optional[Any] ):
														return (
														    F''' Prev -> {self._prev is not None}, Next -> {self._next is not None}'''
														)







				def __init__(				self				:       Any ):
										snake_case__    :   int							     =   self._Node(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ )
										snake_case__    :   Optional[int]							     =   self._Node(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ )
										snake_case__    :   Union[str, Any]							     =   self._trailer
										snake_case__    :   Union[str, Any]							     =   self._header
										snake_case__    :   Any							     =   0

				def __len__(				self				:       str ):
										return self._size

				def  _lowerCamelCase   (				self				:       Union[str, Any] ):
										return self.__len__() == 0

				def  _lowerCamelCase   (				self				:       Any ,SCREAMING_SNAKE_CASE_				:       List[Any] ,SCREAMING_SNAKE_CASE_				:       List[str] ,SCREAMING_SNAKE_CASE_				:       Dict ):
										# Create new_node by setting it's prev.link -> header
										# setting it's next.link -> trailer
										snake_case__    :   Dict							     =   self._Node(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ )
										snake_case__    :   Any							     =   new_node
										snake_case__    :   str							     =   new_node
										self._size += 1
										return self





				def  _lowerCamelCase   (				self				:       Union[str, Any] ,SCREAMING_SNAKE_CASE_				:       Dict ):
										snake_case__    :   Union[str, Any]							     =   node._prev
										snake_case__    :   Union[str, Any]							     =   node._next

										snake_case__    :   List[Any]							     =   successor
										snake_case__    :   Dict							     =   predecessor
										self._size -= 1
										snake_case__    :   Dict							     =   node._data
										snake_case__    :   List[str]							     =   None
										del node
										return temp







class  __lowercase    (     _DoublyLinkedBase		):


				'''simple docstring'''


				def  _lowerCamelCase   (				self				:       Optional[int] ):
										if self.is_empty():
																raise Exception('''List is empty''' )
										return self._header._next._data

				def  _lowerCamelCase   (				self				:       Union[str, Any] ):
										if self.is_empty():
																raise Exception('''List is empty''' )
										return self._trailer._prev._data

				def  _lowerCamelCase   (				self				:       Any ,SCREAMING_SNAKE_CASE_				:       Dict ):
										return self._insert(self._header ,SCREAMING_SNAKE_CASE_ ,self._header._next )

				def  _lowerCamelCase   (				self				:       Dict ,SCREAMING_SNAKE_CASE_				:       Union[str, Any] ):
										return self._insert(self._trailer._prev ,SCREAMING_SNAKE_CASE_ ,self._trailer )

				def  _lowerCamelCase   (				self				:       Optional[int] ):
										if self.is_empty():
																raise IndexError('''remove_first from empty list''' )
										return self._delete(self._header._next )





				def  _lowerCamelCase   (				self				:       Optional[Any] ):
										if self.is_empty():
																raise IndexError('''remove_first from empty list''' )
										return self._delete(self._trailer._prev )


