"""simple docstring"""





from typing import List, Union

from ..utils import (
    add_end_docstrings,
    is_tf_available,
    is_torch_available,
    is_vision_available,
    logging,
    requires_backends,
)
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
				from PIL import Image

				from ..image_utils import load_image

if is_tf_available():
				import tensorflow as tf

				from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
				from ..tf_utils import stable_softmax

if is_torch_available():
				from ..models.auto.modeling_auto import MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING

__A	=					logging.get_logger(__name__)
@add_end_docstrings(__A		)
class 			_snake_case  (       __A		):






						def __init__(							self   :      Tuple				,       *UpperCAmelCase   :      int				,       **UpperCAmelCase   :      Optional[Any]     ):
													super().__init__(*UpperCAmelCase				,       **UpperCAmelCase     )
													requires_backends(self				,       "vision"     )
													self.check_model_type(
													    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
													    if self.framework == "tf"
													    else MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING     )






						def    lowerCamelCase__  (							self   :      str				,       UpperCAmelCase   :      str=None     ):
													__lowerCamelCase       :		Dict		 =  {}
													if top_k is not None:
																				__lowerCamelCase       :		Union[str, Any]		 =  top_k
													return {}, {}, postprocess_params






						def __call__(							self   :      str				,       UpperCAmelCase   :      Union[str, List[str], "Image.Image", List["Image.Image"]]				,       **UpperCAmelCase   :      str     ):
													return super().__call__(UpperCAmelCase				,       **UpperCAmelCase     )






						def    lowerCamelCase__  (							self   :      str				,       UpperCAmelCase   :      Optional[int]     ):
													__lowerCamelCase       :		List[Any]		 =  load_image(UpperCAmelCase     )
													__lowerCamelCase       :		Optional[Any]		 =  self.image_processor(images=UpperCAmelCase				,       return_tensors=self.framework     )
													return model_inputs






						def    lowerCamelCase__  (							self   :      Union[str, Any]				,       UpperCAmelCase   :      Optional[Any]     ):
													__lowerCamelCase       :		str		 =  self.model(**UpperCAmelCase     )
													return model_outputs







						def    lowerCamelCase__  (							self   :      int				,       UpperCAmelCase   :      Optional[Any]				,       UpperCAmelCase   :      Any=5     ):

													if top_k > self.model.config.num_labels:
																				__lowerCamelCase       :		Any		 =  self.model.config.num_labels

													if self.framework == "pt":
																				__lowerCamelCase       :		Dict		 =  model_outputs.logits.softmax(-1     )[0]
																				__lowerCamelCase       :		Dict		 =  probs.topk(UpperCAmelCase     )
													elif self.framework == "tf":
																				__lowerCamelCase       :		Tuple		 =  stable_softmax(model_outputs.logits				,       axis=-1     )[0]
																				__lowerCamelCase       :		Dict		 =  tf.math.top_k(UpperCAmelCase				,       k=UpperCAmelCase     )
																				__lowerCamelCase       :		Any		 =  topk.values.numpy(), topk.indices.numpy()
													else:
																				raise ValueError(F"""Unsupported framework: {self.framework}"""     )

													__lowerCamelCase       :		str		 =  scores.tolist()
													__lowerCamelCase       :		Dict		 =  ids.tolist()
													return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(UpperCAmelCase				,       UpperCAmelCase     )]







'''simple docstring'''



def 				lowercase_					(     __A			:							int       ,   __A			:							int      )							->   int:



 """simple docstring"""




 return 1 if input_a == input_a else 0


def 				lowercase_					(     )							->   None:



 """simple docstring"""




 assert xnor_gate(0       ,   0      ) == 1
 assert xnor_gate(0       ,   1      ) == 0
 assert xnor_gate(1       ,   0      ) == 0
 assert xnor_gate(1       ,   1      ) == 1


if __name__ == "__main__":
      print(xnor_gate(0, 0))
      print(xnor_gate(0, 1))
      print(xnor_gate(1, 0))
      print(xnor_gate(1, 1))



