

import unittest

from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


__A			:					Union[str, Any]						=			get_tests_dir('fixtures/spiece.model')





@require_sentencepiece
@require_tokenizers
class 			_SCREAMING_SNAKE_CASE (   __snake_case					,       unittest.TestCase		):







   '''simple docstring'''




   lowerCamelCase__				=      DebertaVaTokenizer
   lowerCamelCase__				=      DebertaVaTokenizerFast
   lowerCamelCase__				=      True
   lowerCamelCase__				=      True





   def      _snake_case		(       self					:			str			):
       super().setUp()

       # We have a SentencePiece fixture for testing
       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , unk_token="<unk>"			)
       tokenizer.save_pretrained(self.tmpdirname			)





   def      _snake_case		(       self					:			Dict     , __lowerCamelCase					:			List[str]			):
       SCREAMING_SNAKE_CASE										=   "this is a test"
       SCREAMING_SNAKE_CASE										=   "this is a test"
       return input_text, output_text





   def      _snake_case		(       self					:			List[Any]			):
       SCREAMING_SNAKE_CASE										=   "<pad>"
       SCREAMING_SNAKE_CASE										=   0

       self.assertEqual(self.get_tokenizer()._convert_token_to_id(_lowercase			)     , _lowercase			)
       self.assertEqual(self.get_tokenizer()._convert_id_to_token(_lowercase			)     , _lowercase			)





   def      _snake_case		(       self					:			str			):
       SCREAMING_SNAKE_CASE										=   list(self.get_tokenizer().get_vocab().keys()			)
       self.assertEqual(vocab_keys[0]     , "<pad>"			)
       self.assertEqual(vocab_keys[1]     , "<unk>"			)
       self.assertEqual(vocab_keys[-1]     , "[PAD]"			)
       self.assertEqual(len(_lowercase			)     , 30001			)





   def      _snake_case		(       self					:			Optional[Any]			):
       self.assertEqual(self.get_tokenizer().vocab_size     , 30000			)





   def      _snake_case		(       self					:			Dict			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   " \tHeLLo!how  \n Are yoU?  "
       SCREAMING_SNAKE_CASE										=   ["▁hello", "!", "how", "▁are", "▁you", "?"]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , do_lower_case=_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , do_lower_case=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)





   @unittest.skip("There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."			)
   def      _snake_case		(       self					:			Optional[int]			):
       pass





   @unittest.skip("There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."			)
   def      _snake_case		(       self					:			Optional[Any]			):
       pass





   def      _snake_case		(       self					:			List[Any]			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   "I was born in 92000, and this is falsé."
       SCREAMING_SNAKE_CASE										=   ["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			Any			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   "I was born in 92000, and this is falsé."
       SCREAMING_SNAKE_CASE										=   ["▁i", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)
       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)
       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			Union[str, Any]			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   "I was born in 92000, and this is falsé."
       SCREAMING_SNAKE_CASE										=   ["▁i", "▁was", "▁born", "▁in", "▁9", "2000", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", ".", ]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			Any			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   "I was born in 92000, and this is falsé."
       SCREAMING_SNAKE_CASE										=   ["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			Union[str, Any]			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   " \tHeLLo!how  \n Are yoU?  "
       SCREAMING_SNAKE_CASE										=   ["▁", "<unk>", "e", "<unk>", "o", "!", "how", "▁", "<unk>", "re", "▁yo", "<unk>", "?"]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , do_lower_case=_lowercase     , split_by_punct=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)

       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			List[str]			):
       SCREAMING_SNAKE_CASE										=   self.get_tokenizer()
       SCREAMING_SNAKE_CASE										=   self.get_rust_tokenizer()

       SCREAMING_SNAKE_CASE										=   "I was born in 92000, and this is falsé."

       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)			)
       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   self.get_rust_tokenizer()
       SCREAMING_SNAKE_CASE										=   tokenizer.encode(_lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.encode(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			List[str]			):
       SCREAMING_SNAKE_CASE										=   "This is a test"
       SCREAMING_SNAKE_CASE										=   [13, 1, 4398, 25, 21, 1289]
       SCREAMING_SNAKE_CASE										=   ["▁", "T", "his", "▁is", "▁a", "▁test"]
       SCREAMING_SNAKE_CASE										=   ["▁", "<unk>", "his", "▁is", "▁a", "▁test"]

       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase     , keep_accents=_lowercase			)
       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizerFast(_lowercase     , keep_accents=_lowercase			)

       SCREAMING_SNAKE_CASE										=   tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.tokenize(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.tokenize(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)

       # fmt: off
       SCREAMING_SNAKE_CASE										=   "I was born in 92000, and this is falsé."
       SCREAMING_SNAKE_CASE										=   [13, 1, 23, 386, 19, 561, 3050, 15, 17, 48, 25, 8256, 18, 1, 9]
       SCREAMING_SNAKE_CASE										=   ["▁", "I", "▁was", "▁born", "▁in", "▁9", "2000", ",", "▁and", "▁this", "▁is", "▁fal", "s", "é", ".", ]
       SCREAMING_SNAKE_CASE										=   ["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", ".", ]
       # fmt: on

       SCREAMING_SNAKE_CASE										=   tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.tokenize(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.convert_ids_to_tokens(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)

       SCREAMING_SNAKE_CASE										=   rust_tokenizer.encode(_lowercase     , add_special_tokens=_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.tokenize(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)
       SCREAMING_SNAKE_CASE										=   rust_tokenizer.convert_ids_to_tokens(_lowercase			)
       self.assertListEqual(_lowercase     , _lowercase			)





   def      _snake_case		(       self					:			Union[str, Any]			):
       SCREAMING_SNAKE_CASE										=   DebertaVaTokenizer(_lowercase			)

       SCREAMING_SNAKE_CASE										=   tokenizer.encode("sequence builders"			)
       SCREAMING_SNAKE_CASE										=   tokenizer.encode("multi-sequence build"			)

       SCREAMING_SNAKE_CASE										=   tokenizer.build_inputs_with_special_tokens(_lowercase			)
       SCREAMING_SNAKE_CASE										=   tokenizer.build_inputs_with_special_tokens(_lowercase     , _lowercase			)

       self.assertEqual([tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]     , _lowercase			)
       self.assertEqual(
           [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [tokenizer.sep_token_id]     , _lowercase     , )





   @slow
   def      _snake_case		(       self					:			List[Any]			):
       # fmt: off
       SCREAMING_SNAKE_CASE										=   {"input_ids": [[1, 39867, 36, 19390, 486, 27, 35052, 81436, 18, 60685, 1225, 7, 35052, 81436, 18, 9367, 16899, 18, 15937, 53, 594, 773, 18, 16287, 30465, 36, 15937, 6, 41139, 38, 36979, 60763, 191, 6, 34132, 99, 6, 50538, 390, 43230, 6, 34132, 2779, 20850, 14, 699, 1072, 1194, 36, 382, 10901, 53, 7, 699, 1072, 2084, 36, 20422, 630, 53, 19, 105, 3049, 1896, 1053, 16899, 1506, 11, 37978, 4243, 7, 1237, 31869, 200, 16566, 654, 6, 35052, 81436, 7, 55630, 13593, 4, 2], [1, 26, 15011, 13, 667, 8, 1053, 18, 23611, 1237, 72356, 12820, 34, 104134, 1209, 35, 13313, 6627, 21, 202, 347, 7, 164, 2399, 11, 46, 4485, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 5, 1232, 2864, 15785, 14951, 105, 5, 8581, 1250, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "token_type_ids": [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "attention_mask": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
       # fmt: on

       self.tokenizer_integration_test_util(
           expected_encoding=_lowercase     , model_name="microsoft/deberta-v2-xlarge"     , revision="ad6e42c1532ddf3a15c39246b63f5559d558b670"     , )





'''simple docstring'''
from collections import UserDict
from typing import List, Union

from ..utils import (
    add_end_docstrings,
    is_tf_available,
    is_torch_available,
    is_vision_available,
    logging,
    requires_backends,
)
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
							from PIL import Image

							from ..image_utils import load_image

if is_torch_available():
							from ..models.auto.modeling_auto import MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING

if is_tf_available():
							from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING
							from ..tf_utils import stable_softmax

_SCREAMING_SNAKE_CASE			=						logging.get_logger(__name__)
@add_end_docstrings(lowerCAmelCase				)
class   __UpperCAmelCase				(     lowerCAmelCase				):



					'''simple docstring'''





					def __init__(	self     :						int      ,       **_lowercase     :						List[Any])    ->							Union[str, Any]:
								super().__init__(**_lowercase)

								requires_backends(self      ,       'vision')
								self.check_model_type(
								    TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING
								    if self.framework == 'tf'
								    else MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING)



					def __call__(	self     :						Optional[Any]      ,       _lowercase     :						Union[str, List[str], "Image", List["Image"]]      ,       **_lowercase     :						List[Any])    ->							Any:
								return super().__call__(_lowercase      ,       **_lowercase)



					def     __snake_case						(	self     :						int      ,       **_lowercase     :						Union[str, Any])    ->							Any:
								A_									= {}
								if "candidate_labels" in kwargs:
											A_									= kwargs['candidate_labels']
								if "hypothesis_template" in kwargs:
											A_									= kwargs['hypothesis_template']

								return preprocess_params, {}, {}



					def     __snake_case						(	self     :						List[str]      ,       _lowercase     :						Tuple      ,       _lowercase     :						Any=None      ,       _lowercase     :						Optional[int]="This is a photo of {}.")    ->							Union[str, Any]:
								A_									= load_image(_lowercase)
								A_									= self.image_processor(images=[image]      ,       return_tensors=self.framework)
								A_									= candidate_labels
								A_									= [hypothesis_template.format(_lowercase) for x in candidate_labels]
								A_									= self.tokenizer(_lowercase      ,       return_tensors=self.framework      ,       padding=_lowercase)
								A_									= [text_inputs]
								return inputs



					def     __snake_case						(	self     :						Optional[int]      ,       _lowercase     :						Tuple)    ->							Optional[int]:
								A_									= model_inputs.pop('candidate_labels')
								A_									= model_inputs.pop('text_inputs')
								if isinstance(text_inputs[0]      ,       _lowercase):
											A_									= text_inputs[0]
								else:
											# Batching case.
											A_									= text_inputs[0][0]

								A_									= self.model(**_lowercase      ,       **_lowercase)

								A_									= {
								    'candidate_labels': candidate_labels,
								    'logits': outputs.logits_per_image,
								}
								return model_outputs



					def     __snake_case						(	self     :						List[str]      ,       _lowercase     :						int)    ->							Optional[int]:
								A_									= model_outputs.pop('candidate_labels')
								A_									= model_outputs['logits'][0]
								if self.framework == "pt":
											A_									= logits.softmax(dim=-1).squeeze(-1)
											A_									= probs.tolist()
											if not isinstance(_lowercase      ,       _lowercase):
														A_									= [scores]
								elif self.framework == "tf":
											A_									= stable_softmax(_lowercase      ,       axis=-1)
											A_									= probs.numpy().tolist()
								else:
											raise ValueError(F'Unsupported framework: {self.framework}')

								A_									= [
								    {'score': score, 'label': candidate_label}
								    for score, candidate_label in sorted(zip(_lowercase      ,       _lowercase)      ,       key=lambda _lowercase: -x[0])
								]
								return result




