"""simple docstring"""
import numpy as np

from transformers import Pipeline





def    lowerCAmelCase__    (			_UpperCamelCase       :				Tuple					)					->				str:





						"""simple docstring"""






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



class   lowerCAmelCase_    (			lowerCAmelCase					):



				"""simple docstring"""

				def 		snake_case (				self		,    **lowerCAmelCase    ):






										"""simple docstring"""

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

				def 		snake_case (				self		,    lowerCAmelCase		,    lowerCAmelCase=None    ):






										"""simple docstring"""

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

				def 		snake_case (				self		,    lowerCAmelCase    ):






										"""simple docstring"""

										return self.model(**lowerCAmelCase    )

				def 		snake_case (				self		,    lowerCAmelCase    ):






										"""simple docstring"""

										snake_case								=			model_outputs.logits[0].numpy()
										snake_case								=			softmax(lowerCAmelCase    )

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



"""simple docstring"""
from abc import ABC, abstractmethod
from typing import Optional, Union

from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit
from ..utils.typing import NestedDataStructureLike, PathLike



class   lowerCAmelCase_    (			lowerCAmelCase					):



				"""simple docstring"""

				def __init__(				self		,    lowerCAmelCase = None		,    lowerCAmelCase = None		,    lowerCAmelCase = None		,    lowerCAmelCase = None		,    lowerCAmelCase = False		,    lowerCAmelCase = False		,    lowerCAmelCase = None		,    **lowerCAmelCase		,    ):






										"""simple docstring"""

										snake_case								=			path_or_paths
										snake_case								=			split if split or isinstance(lowerCAmelCase		,    lowerCAmelCase    ) else 'train'
										snake_case								=			features
										snake_case								=			cache_dir
										snake_case								=			keep_in_memory
										snake_case								=			streaming
										snake_case								=			num_proc
										snake_case								=			kwargs

				@abstractmethod
				def 		snake_case (				self    ):






										"""simple docstring"""

										pass





class   lowerCAmelCase_    (			lowerCAmelCase					):



				"""simple docstring"""

				def __init__(				self		,    lowerCAmelCase = None		,    lowerCAmelCase = None		,    lowerCAmelCase = False		,    lowerCAmelCase = False		,    lowerCAmelCase = None		,    **lowerCAmelCase		,    ):






										"""simple docstring"""

										snake_case								=			features
										snake_case								=			cache_dir
										snake_case								=			keep_in_memory
										snake_case								=			streaming
										snake_case								=			num_proc
										snake_case								=			kwargs

				@abstractmethod
				def 		snake_case (				self    ):






										"""simple docstring"""

										pass


