
"""simple docstring"""



import numpy as np

from transformers import Pipeline






def 						__snake_case	(     SCREAMING_SNAKE_CASE:       Optional[int]    ):






							"""simple docstring"""



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

class 							_SCREAMING_SNAKE_CASE	(	UpperCAmelCase				):






				'''simple docstring'''



				def 					__lowerCamelCase						(       self						:      Optional[Any]					,  **UpperCAmelCase_						:      int	)		->	Optional[int]:







											"""simple docstring"""




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


				def 					__lowerCamelCase						(       self						:      str					,  UpperCAmelCase_						:      Union[str, Any]					,  UpperCAmelCase_						:      Optional[Any]=None	)		->	int:







											"""simple docstring"""




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


				def 					__lowerCamelCase						(       self						:      List[Any]					,  UpperCAmelCase_						:      List[str]	)		->	str:







											"""simple docstring"""




											return self.model(**UpperCAmelCase_	)







				def 					__lowerCamelCase						(       self						:      List[Any]					,  UpperCAmelCase_						:      Optional[Any]	)		->	Dict:







											"""simple docstring"""




											_lowerCAmelCase							=      model_outputs.logits[0].numpy()
											_lowerCAmelCase							=      softmax(UpperCAmelCase_	)

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












"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase__			=		logging.get_logger(__name__)

lowercase__			=		{"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""}






class lowerCAmelCase__      (	lowercase		):






			'''simple docstring'''



			lowerCamelCase__ =     """openai-gpt"""
			lowerCamelCase__ =     {
			    """max_position_embeddings""": """n_positions""",
			    """hidden_size""": """n_embd""",
			    """num_attention_heads""": """n_head""",
			    """num_hidden_layers""": """n_layer""",
			}
			def __init__(    self    , lowercase=40478    , lowercase=512    , lowercase=768    , lowercase=12    , lowercase=12    , lowercase="gelu"    , lowercase=0.1    , lowercase=0.1    , lowercase=0.1    , lowercase=1E-5    , lowercase=0.02    , lowercase="cls_index"    , lowercase=True    , lowercase=None    , lowercase=True    , lowercase=0.1    , **lowercase    , ):
							_lowerCamelCase	:     Tuple       =       vocab_size
							_lowerCamelCase	:     List[str]       =       n_positions
							_lowerCamelCase	:     Tuple       =       n_embd
							_lowerCamelCase	:     Optional[int]       =       n_layer
							_lowerCamelCase	:     List[Any]       =       n_head
							_lowerCamelCase	:     Dict       =       afn
							_lowerCamelCase	:     Union[str, Any]       =       resid_pdrop
							_lowerCamelCase	:     Dict       =       embd_pdrop
							_lowerCamelCase	:     List[Any]       =       attn_pdrop
							_lowerCamelCase	:     Any       =       layer_norm_epsilon
							_lowerCamelCase	:     List[Any]       =       initializer_range
							_lowerCamelCase	:     List[Any]       =       summary_type
							_lowerCamelCase	:     List[str]       =       summary_use_proj
							_lowerCamelCase	:     Tuple       =       summary_activation
							_lowerCamelCase	:     int       =       summary_first_dropout
							_lowerCamelCase	:     str       =       summary_proj_to_labels
							super().__init__(**lowercase    )