


import numpy as np

from transformers import Pipeline
def      snake_case_						( __lowercase       ):
   UpperCAmelCase_							:      List[str]						=   np.max(__lowercase			,       axis=-1			,       keepdims=__lowercase       )
   UpperCAmelCase_							:      int						=   np.exp(outputs - maxes       )
   return shifted_exp / shifted_exp.sum(axis=-1			,       keepdims=__lowercase       )





class  lowerCAmelCase__(    snake_case__						):






    '''simple docstring'''





    def 					_lowerCamelCase (	self				:   Dict       ,   **__snake_case				:   List[Any]	):





       '''simple docstring'''
       UpperCAmelCase_							:      List[Any]						=   {}
       if "second_text" in kwargs:
          UpperCAmelCase_							:      List[str]						=   kwargs['''second_text''']
       return preprocess_kwargs, {}, {}





    def 					_lowerCamelCase (	self				:   Dict       ,   __snake_case				:   Union[str, Any]       ,   __snake_case				:   Tuple=None	):





       '''simple docstring'''
       return self.tokenizer(__snake_case       ,   text_pair=__snake_case       ,   return_tensors=self.framework	)





    def 					_lowerCamelCase (	self				:   Union[str, Any]       ,   __snake_case				:   Optional[Any]	):





       '''simple docstring'''
       return self.model(**__snake_case	)





    def 					_lowerCamelCase (	self				:   Union[str, Any]       ,   __snake_case				:   Optional[int]	):





       '''simple docstring'''
       UpperCAmelCase_							:      Union[str, Any]						=   model_outputs.logits[0].numpy()
       UpperCAmelCase_							:      Optional[Any]						=   softmax(__snake_case	)

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



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__UpperCamelCase				:  str      					=							{
    'configuration_x_clip': [
        'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'XCLIPConfig',
        'XCLIPTextConfig',
        'XCLIPVisionConfig',
    ],
    'processing_x_clip': ['XCLIPProcessor'],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __UpperCamelCase				:  Any      					=							[
           'XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST',
           'XCLIPModel',
           'XCLIPPreTrainedModel',
           'XCLIPTextModel',
           'XCLIPVisionModel',
       ]

if TYPE_CHECKING:
       from .configuration_x_clip import (
           XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
           XCLIPConfig,
           XCLIPTextConfig,
           XCLIPVisionConfig,
       )
       from .processing_x_clip import XCLIPProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_x_clip import (
                  XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
                  XCLIPModel,
                  XCLIPPreTrainedModel,
                  XCLIPTextModel,
                  XCLIPVisionModel,
              )

else:
       import sys

       __UpperCamelCase				:  List[str]      					=							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)