




import numpy as np

from transformers import Pipeline

def      A      (      _SCREAMING_SNAKE_CASE    )	-> Optional[int]:
       lowerCamelCase   :      Dict			 =					np.max(_SCREAMING_SNAKE_CASE ,axis=-1 ,keepdims=_SCREAMING_SNAKE_CASE    )
       lowerCamelCase   :      Dict			 =					np.exp(outputs - maxes    )
       return shifted_exp / shifted_exp.sum(axis=-1 ,keepdims=_SCREAMING_SNAKE_CASE    )




class 		UpperCamelCase__	(lowerCAmelCase__     ):

    '''simple docstring'''



    def     _lowercase     (    self     ,  **UpperCamelCase__     )     ->      Dict:
           lowerCamelCase   :      Optional[Any]			 =					{}
           if "second_text" in kwargs:
                  lowerCamelCase   :      Union[str, Any]			 =					kwargs["second_text"]
           return preprocess_kwargs, {}, {}







    def     _lowercase     (    self     ,  UpperCamelCase__     ,  UpperCamelCase__=None     )     ->      int:
           return self.tokenizer(UpperCamelCase__     ,  text_pair=UpperCamelCase__     ,  return_tensors=self.framework     )







    def     _lowercase     (    self     ,  UpperCamelCase__     )     ->      str:
           return self.model(**UpperCamelCase__     )







    def     _lowercase     (    self     ,  UpperCamelCase__     )     ->      Optional[Any]:
           lowerCamelCase   :      str			 =					model_outputs.logits[0].numpy()
           lowerCamelCase   :      Any			 =					softmax(UpperCamelCase__     )

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












from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


UpperCAmelCase_									=	{
    'configuration_vision_encoder_decoder': ['VisionEncoderDecoderConfig', 'VisionEncoderDecoderOnnxConfig']
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase_									=	['VisionEncoderDecoderModel']

try:
       if not is_tf_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase_									=	['TFVisionEncoderDecoderModel']

try:
       if not is_flax_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase_									=	['FlaxVisionEncoderDecoderModel']

if TYPE_CHECKING:
       from .configuration_vision_encoder_decoder import VisionEncoderDecoderConfig, VisionEncoderDecoderOnnxConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_vision_encoder_decoder import VisionEncoderDecoderModel

       try:
              if not is_tf_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_tf_vision_encoder_decoder import TFVisionEncoderDecoderModel

       try:
              if not is_flax_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_flax_vision_encoder_decoder import FlaxVisionEncoderDecoderModel

else:
       import sys

       UpperCAmelCase_									=	_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

