

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


__lowercase     : Dict       =						logging.get_logger(__name__)

__lowercase     : Tuple       =						{
    '''shi-labs/nat-mini-in1k-224''': '''https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json''',
    # See all Nat models at https://huggingface.co/models?filter=nat
}



class 						_A     (				snake_case						,    snake_case				):





  '''simple docstring'''



  __lowerCamelCase			:      List[str]					=   '''nat'''

  __lowerCamelCase			:      List[Any]					=   {
      '''num_attention_heads''': '''num_heads''',
      '''num_hidden_layers''': '''num_layers''',
  }





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

      '''simple docstring'''
      super().__init__(**SCREAMING_SNAKE_CASE_    )

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









'''simple docstring'''


from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass

@dataclass
class      A       :
							lowercase_							     =							42
							lowercase_							     =							42



class      A       :







							def __init__(    self			:    Optional[Any]				,     lowerCAmelCase_			:    int   )     ->				str:


														"""simple docstring"""


														_a      	=							[[] for _ in range(lowerCAmelCase_   )]
														_a      	=							size







							def __getitem__(    self			:    Any				,     lowerCAmelCase_			:    int   )     ->				Iterator[Edge]:


														"""simple docstring"""


														return iter(self._graph[vertex]   )







							@property
							def   __lowerCAmelCase     (    self			:    str   )     ->				Tuple:


														"""simple docstring"""


														return self._size







							def   __lowerCAmelCase     (    self			:    Union[str, Any]				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    int   )     ->				Dict:


														"""simple docstring"""


														if weight not in (0, 1):
																					raise ValueError('''Edge weight must be either 0 or 1.'''   )

														if to_vertex < 0 or to_vertex >= self.size:
																					raise ValueError('''Vertex indexes must be in [0; size).'''   )

														self._graph[from_vertex].append(Edge(lowerCAmelCase_				,     lowerCAmelCase_   )   )







							def   __lowerCAmelCase     (    self			:    Tuple				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    int   )     ->				int | None:


														"""simple docstring"""


														_a      	=							deque([start_vertex]   )
														_a      	=							[None] * self.size
														_a      	=							0

														while queue:
																					_a      	=							queue.popleft()
																					_a      	=							distances[current_vertex]
																					if current_distance is None:
																												continue

																					for edge in self[current_vertex]:
																												_a      	=							current_distance + edge.weight
																												_a      	=							distances[edge.destination_vertex]
																												if (
																												    isinstance(lowerCAmelCase_				,     lowerCAmelCase_   )
																												    and new_distance >= dest_vertex_distance
																												):
																																			continue
																												_a      	=							new_distance
																												if edge.weight == 0:
																																			queue.appendleft(edge.destination_vertex   )
																												else:
																																			queue.append(edge.destination_vertex   )

														if distances[finish_vertex] is None:
																					raise ValueError('''No path from start_vertex to finish_vertex.'''   )

														return distances[finish_vertex]


if __name__ == "__main__":
				import doctest

				doctest.testmod()

