




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


__A        =    logging.get_logger(__name__)

__A        =    {
    "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     __lowerCAmelCase (       __magic_name__			,				__magic_name__ ):

			"""simple docstring"""







			snake_case_   		=       '''nat'''

			snake_case_   		=       {
			    '''num_attention_heads''': '''num_heads''',
			    '''num_hidden_layers''': '''num_layers''',
			}


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



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

							__lowerCamelCase		       =    patch_size
							__lowerCamelCase		       =    num_channels
							__lowerCamelCase		       =    embed_dim
							__lowerCamelCase		       =    depths
							__lowerCamelCase		       =    len(lowerCamelCase__							)
							__lowerCamelCase		       =    num_heads
							__lowerCamelCase		       =    kernel_size
							__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 Nat work with VisionEncoderDecoderModel
							# this indicates the channel dimension after the last stage of the model
							__lowerCamelCase		       =    int(embed_dim * 2 ** (len(lowerCamelCase__							) - 1)							)
							__lowerCamelCase		       =    layer_scale_init_value
							__lowerCamelCase		       =    ['stem'] + [f"""stage{idx}""" for idx in range(1			,						len(lowerCamelCase__							) + 1							)]
							__lowerCamelCase       ,						__lowerCamelCase		       =    get_aligned_output_features_output_indices(
							    out_features=lowerCamelCase__			,						out_indices=lowerCamelCase__			,						stage_names=self.stage_names							)








class     __lowerCAmelCase :

			"""simple docstring"""







			def __init__(      self			,						lowerCamelCase__							)    ->      Any:



							'''simple docstring'''
							__lowerCamelCase		       =    n
							__lowerCamelCase		       =    [None] * self.n
							__lowerCamelCase		       =    0  # index of the first element
							__lowerCamelCase		       =    0
							__lowerCamelCase		       =    0


			def __len__(      self							)    ->      int:



							'''simple docstring'''
							return self.size


			def       lowercase_    (      self							)    ->      bool:



							'''simple docstring'''
							return self.size == 0


			def       lowercase_    (      self							)    ->      str:



							'''simple docstring'''
							return False if self.is_empty() else self.array[self.front]


			def       lowercase_    (      self			,						lowerCamelCase__							)    ->      Optional[Any]:



							'''simple docstring'''
							if self.size >= self.n:
											raise Exception('QUEUE IS FULL'							)

							__lowerCamelCase		       =    data
							__lowerCamelCase		       =    (self.rear + 1) % self.n
							self.size += 1
							return self






			def       lowercase_    (      self							)    ->      Tuple:



							'''simple docstring'''
							if self.size == 0:
											raise Exception('UNDERFLOW'							)

							__lowerCamelCase		       =    self.array[self.front]
							__lowerCamelCase		       =    None
							__lowerCamelCase		       =    (self.front + 1) % self.n
							self.size -= 1
							return temp


