


'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase__  			=				{
    '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LlamaConfig'''],
}

try:
					if not is_sentencepiece_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase__  			=				['''LlamaTokenizer''']

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase__  			=				['''LlamaTokenizerFast''']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase__  			=				[
					    '''LlamaForCausalLM''',
					    '''LlamaModel''',
					    '''LlamaPreTrainedModel''',
					    '''LlamaForSequenceClassification''',
					]


if TYPE_CHECKING:
					from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

					try:
										if not is_sentencepiece_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_llama import LlamaTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_llama_fast import LlamaTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
					import sys

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







'''simple docstring'''





import numpy as np

from transformers import Pipeline






def 						UpperCAmelCase__(				_SCREAMING_SNAKE_CASE					: Any ):






			"""simple docstring"""




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






class 						a__					(					a_   ):





			'''simple docstring'''

			def 					lowerCAmelCase     (  self							:			Optional[Any]			,    **lowerCAmelCase_							:			List[str]	)      ->		List[str]:
						__A=	{}
						if "second_text" in kwargs:
									__A=	kwargs['second_text']
						return preprocess_kwargs, {}, {}
			def 					lowerCAmelCase     (  self							:			str			,    lowerCAmelCase_							:			Union[str, Any]			,    lowerCAmelCase_							:			Optional[int]=None	)      ->		int:
						return self.tokenizer(lowerCAmelCase_			,    text_pair=lowerCAmelCase_			,    return_tensors=self.framework	)
			def 					lowerCAmelCase     (  self							:			Dict			,    lowerCAmelCase_							:			List[str]	)      ->		Tuple:
						return self.model(**lowerCAmelCase_	)

			def 					lowerCAmelCase     (  self							:			str			,    lowerCAmelCase_							:			Dict	)      ->		Optional[int]:
						__A=	model_outputs.logits[0].numpy()
						__A=	softmax(lowerCAmelCase_	)

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



