






'''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


lowerCamelCase_				: Union[str, Any]    	=							logging.get_logger(__name__)

lowerCamelCase_				: List[str]    	=							{
    '''google/mobilenet_v1_1.0_224''': '''https://huggingface.co/google/mobilenet_v1_1.0_224/resolve/main/config.json''',
    '''google/mobilenet_v1_0.75_192''': '''https://huggingface.co/google/mobilenet_v1_0.75_192/resolve/main/config.json''',
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
}
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			__a							:							Optional[Any]					     =					"mobilenet_v1"






			def __init__(   self							:						int ,      lowercase							:						Union[str, Any]=3 ,      lowercase							:						List[Any]=2_2_4 ,      lowercase							:						Any=1.0 ,      lowercase							:						Any=8 ,      lowercase							:						Optional[Any]="relu6" ,      lowercase							:						str=True ,      lowercase							:						str=0.9_9_9 ,      lowercase							:						Dict=0.0_2 ,      lowercase							:						Any=0.0_0_1 ,      **lowercase							:						int ,      )							->    int:

									'''simple docstring'''







									super().__init__(**lowercase			)

									if depth_multiplier <= 0:
															raise ValueError("""depth_multiplier must be greater than zero."""			)

									UpperCamelCase__         = num_channels
									UpperCamelCase__         = image_size
									UpperCamelCase__         = depth_multiplier
									UpperCamelCase__         = min_depth
									UpperCamelCase__         = hidden_act
									UpperCamelCase__         = tf_padding
									UpperCamelCase__         = classifier_dropout_prob
									UpperCamelCase__         = initializer_range
									UpperCamelCase__         = layer_norm_eps
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			__a							:							Dict					     =					version.parse("1.11"	)






			@property
			def 				A      (   self							:						Dict			)							->    Mapping[str, Mapping[int, str]]:

									'''simple docstring'''







									return OrderedDict([("""pixel_values""", {0: """batch"""})]			)






			@property
			def 				A      (   self							:						List[str]			)							->    Mapping[str, Mapping[int, str]]:

									'''simple docstring'''







									if self.task == "image-classification":
															return OrderedDict([("""logits""", {0: """batch"""})]			)
									else:
															return OrderedDict([("""last_hidden_state""", {0: """batch"""}), ("""pooler_output""", {0: """batch"""})]			)







			@property
			def 				A      (   self							:						Optional[Any]			)							->    float:

									'''simple docstring'''







									return 1e-4








'''simple docstring'''


import numpy as np

from transformers import Pipeline







def 	__magic_name__( _A					):
						'''simple docstring'''





						UpperCamelCase__         = np.max(_A						,      axis=-1						,      keepdims=_A					)
						UpperCamelCase__         = np.exp(outputs - maxes					)
						return shifted_exp / shifted_exp.sum(axis=-1						,      keepdims=_A					)







class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			def 				A      (   self							:						int ,      **lowercase							:						List[Any]			)							->    List[str]:

									'''simple docstring'''







									UpperCamelCase__         = {}
									if "second_text" in kwargs:
															UpperCamelCase__         = kwargs["""second_text"""]
									return preprocess_kwargs, {}, {}






			def 				A      (   self							:						Optional[int] ,      lowercase							:						Union[str, Any] ,      lowercase							:						Any=None			)							->    Optional[int]:

									'''simple docstring'''







									return self.tokenizer(lowercase ,      text_pair=lowercase ,      return_tensors=self.framework			)






			def 				A      (   self							:						Union[str, Any] ,      lowercase							:						Optional[int]			)							->    Any:

									'''simple docstring'''







									return self.model(**lowercase			)







			def 				A      (   self							:						List[str] ,      lowercase							:						Any			)							->    Optional[int]:

									'''simple docstring'''







									UpperCamelCase__         = model_outputs.logits[0].numpy()
									UpperCamelCase__         = softmax(lowercase			)

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