


'''simple docstring'''

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


_UpperCAmelCase				: Optional[int]							    =				logging.get_logger(__name__)

_UpperCAmelCase				: Optional[int]							    =				{
    """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__				( lowercase__							,						lowercase__      ):







				"""simple docstring"""



				__UpperCamelCase    :		str	=	'nat'

				__UpperCamelCase    :		Optional[Any]	=	{
				    'num_attention_heads': 'num_heads',
				    'num_hidden_layers': 'num_layers',
				}




				def __init__(self       ,			__lowercase=4       ,			__lowercase=3       ,			__lowercase=64       ,			__lowercase=[3, 4, 6, 5]       ,			__lowercase=[2, 4, 8, 16]       ,			__lowercase=7       ,			__lowercase=3.0       ,			__lowercase=True       ,			__lowercase=0.0       ,			__lowercase=0.0       ,			__lowercase=0.1       ,			__lowercase="gelu"       ,			__lowercase=0.0_2       ,			__lowercase=1e-5       ,			__lowercase=0.0       ,			__lowercase=None       ,			__lowercase=None       ,			**__lowercase       ,			):
										super().__init__(**__lowercase		)

										__lowerCAmelCase							       =				patch_size
										__lowerCAmelCase							       =				num_channels
										__lowerCAmelCase							       =				embed_dim
										__lowerCAmelCase							       =				depths
										__lowerCAmelCase							       =				len(__lowercase		)
										__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(__lowercase		) - 1)		)
										__lowerCAmelCase							       =				layer_scale_init_value
										__lowerCAmelCase							       =				['''stem'''] + [F"""stage{idx}""" for idx in range(1       ,			len(__lowercase		) + 1		)]
										__lowerCAmelCase       ,					__lowerCAmelCase							       =				get_aligned_output_features_output_indices(
										    out_features=__lowercase       ,			out_indices=__lowercase       ,			stage_names=self.stage_names		)







'''simple docstring'''

import numpy as np

from transformers import Pipeline

def 							__magic_name__(						lowerCamelCase):
						__lowerCAmelCase							       =				np.max(lowerCamelCase,				axis=-1,				keepdims=lowerCamelCase)
						__lowerCAmelCase							       =				np.exp(outputs - maxes)
						return shifted_exp / shifted_exp.sum(axis=-1,				keepdims=lowerCamelCase)




class       a__				( __A      ):







				"""simple docstring"""



				def 					_snake_case  (self       ,			**__lowercase		):
										__lowerCAmelCase							       =				{}
										if "second_text" in kwargs:
																__lowerCAmelCase							       =				kwargs['''second_text''']
										return preprocess_kwargs, {}, {}




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase=None		):
										return self.tokenizer(__lowercase       ,			text_pair=__lowercase       ,			return_tensors=self.framework		)




				def 					_snake_case  (self       ,			__lowercase		):
										return self.model(**__lowercase		)




				def 					_snake_case  (self       ,			__lowercase		):
										__lowerCAmelCase							       =				model_outputs.logits[0].numpy()
										__lowerCAmelCase							       =				softmax(__lowercase		)

										__lowerCAmelCase							       =				np.argmax(__lowercase		)
										__lowerCAmelCase							       =				self.model.config.idalabel[best_class]
										__lowerCAmelCase							       =				probabilities[best_class].item()
										__lowerCAmelCase							       =				logits.tolist()
										return {"label": label, "score": score, "logits": logits}

