import numpy as np

from transformers import Pipeline
def 							lowerCAmelCase(     __lowerCamelCase						):
					__a		 =       np.max(__lowerCamelCase				,    axis=-1				,    keepdims=__lowerCamelCase						)
					__a		 =       np.exp(outputs - maxes						)
					return shifted_exp / shifted_exp.sum(axis=-1				,    keepdims=__lowerCamelCase						)



class 						a__					(       __snake_case		):



			def __SCREAMING_SNAKE_CASE							(						self				,						**UpperCAmelCase   )			->   int:
								__a		 =       {}
								if "second_text" in kwargs:
													__a		 =       kwargs['second_text']
								return preprocess_kwargs, {}, {}



			def __SCREAMING_SNAKE_CASE							(						self				,						UpperCAmelCase				,						UpperCAmelCase=None   )			->   Dict:
								return self.tokenizer(UpperCAmelCase				,						text_pair=UpperCAmelCase				,						return_tensors=self.framework   )



			def __SCREAMING_SNAKE_CASE							(						self				,						UpperCAmelCase   )			->   Union[str, Any]:
								return self.model(**UpperCAmelCase   )







			def __SCREAMING_SNAKE_CASE							(						self				,						UpperCAmelCase   )			->   List[str]:
								__a		 =       model_outputs.logits[0].numpy()
								__a		 =       softmax(UpperCAmelCase   )

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





from datetime import datetime

import matplotlib.pyplot as plt
import torch
def 							lowerCAmelCase(     __lowerCamelCase						):
					for param in module.parameters():
										__a		 =       False
def 							lowerCAmelCase(     ):
					__a		 =       'cuda' if torch.cuda.is_available() else 'cpu'
					if torch.backends.mps.is_available() and torch.backends.mps.is_built():
										__a		 =       'mps'
					if device == "mps":
										print(
										    'WARNING: MPS currently doesn\'t seem to work, and messes up backpropagation without any visible torch'
										    ' errors. I recommend using CUDA on a colab notebook or CPU instead if you\'re facing inexplicable issues'
										    ' with generations.'						)
					return device
def 							lowerCAmelCase(     __lowerCamelCase						):
					__a		 =       plt.imshow(__lowerCamelCase						)
					fig.axes.get_xaxis().set_visible(__lowerCamelCase						)
					fig.axes.get_yaxis().set_visible(__lowerCamelCase						)
					plt.show()



def 							lowerCAmelCase(     ):
					__a		 =       datetime.now()
					__a		 =       current_time.strftime('%H:%M:%S'						)
					return timestamp




