


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


_lowercase							:   Any						=						{
    "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "M2M100OnnxConfig"],
    "tokenization_m2m_100": ["M2M100Tokenizer"],
}


try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowercase							:   int						=						[
				    "M2M_100_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "M2M100ForConditionalGeneration",
				    "M2M100Model",
				    "M2M100PreTrainedModel",
				]


if TYPE_CHECKING:
				from .configuration_mam_aaa import M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP, MaMaaaConfig, MaMaaaOnnxConfig
				from .tokenization_mam_aaa import MaMaaaTokenizer

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_mam_aaa import (
								    M2M_100_PRETRAINED_MODEL_ARCHIVE_LIST,
								    MaMaaaForConditionalGeneration,
								    MaMaaaModel,
								    MaMaaaPreTrainedModel,
								)


else:
				import sys

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







import numpy as np

from transformers import Pipeline





def 	_lowerCAmelCase					( UpperCamelCase__:  Optional[Any]    )			-> Optional[int]:





	"""simple docstring"""







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






class    _UpperCamelCase     (       __snake_case					):

				"""simple docstring"""







				def   _UpperCAmelCase       (    self					, **a__ )						->					Union[str, Any]:
					A             =					{}
					if "second_text" in kwargs:
						A             =					kwargs["""second_text"""]
					return preprocess_kwargs, {}, {}

				def   _UpperCAmelCase       (    self					, a__					, a__=None )						->					str:
					return self.tokenizer(a__					, text_pair=a__					, return_tensors=self.framework )

				def   _UpperCAmelCase       (    self					, a__ )						->					Tuple:
					return self.model(**a__ )

				def   _UpperCAmelCase       (    self					, a__ )						->					Optional[int]:
					A             =					model_outputs.logits[0].numpy()
					A             =					softmax(a__ )

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



