

from __future__ import annotations

import time
from collections.abc import Sequence
from random import randint

from matplotlib import pyplot as plt
def 						_snake_case(   SCREAMING_SNAKE_CASE__      :     Sequence[float]   ,      SCREAMING_SNAKE_CASE__      :     int   ,      SCREAMING_SNAKE_CASE__      :     int				)							->				tuple[int | None, int | None, float]:





				'''simple docstring'''






				if not arr:
								return None, None, 0
				if low == high:
								return low, high, arr[low]

				A__   				=       (low + high) // 2
				A__				,						A__				,						A__   				=       max_subarray(SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__				)
				A__				,						A__				,						A__   				=       max_subarray(SCREAMING_SNAKE_CASE__   ,      mid + 1   ,      SCREAMING_SNAKE_CASE__				)
				A__				,						A__				,						A__   				=       max_cross_sum(SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__				)
				if left_sum >= right_sum and left_sum >= cross_sum:
								return left_low, left_high, left_sum
				elif right_sum >= left_sum and right_sum >= cross_sum:
								return right_low, right_high, right_sum
				return cross_left, cross_right, cross_sum
def 						_snake_case(   SCREAMING_SNAKE_CASE__      :     Sequence[float]   ,      SCREAMING_SNAKE_CASE__      :     int   ,      SCREAMING_SNAKE_CASE__      :     int   ,      SCREAMING_SNAKE_CASE__      :     int				)							->				tuple[int, int, float]:





				'''simple docstring'''






				A__				,						A__   				=       float('-inf'				), -1
				A__				,						A__   				=       float('-inf'				), -1

				A__   				=       0
				for i in range(SCREAMING_SNAKE_CASE__   ,      low - 1   ,      -1				):
								summ += arr[i]
								if summ > left_sum:
												A__   				=       summ
												A__   				=       i

				A__   				=       0
				for i in range(mid + 1   ,      high + 1				):
								summ += arr[i]
								if summ > right_sum:
												A__   				=       summ
												A__   				=       i

				return max_left, max_right, (left_sum + right_sum)
def 						_snake_case(   SCREAMING_SNAKE_CASE__      :     int				)							->				float:





				'''simple docstring'''






				A__   				=       [randint(1   ,      SCREAMING_SNAKE_CASE__				) for _ in range(SCREAMING_SNAKE_CASE__				)]
				A__   				=       time.time()
				max_subarray(SCREAMING_SNAKE_CASE__   ,      0   ,      input_size - 1				)
				A__   				=       time.time()
				return end - start
def 						_snake_case(   )							->				None:





				'''simple docstring'''






				A__   				=       [10, 100, 1000, 10000, 50000, 100000, 200000, 300000, 400000, 500000]
				A__   				=       [time_max_subarray(SCREAMING_SNAKE_CASE__				) for input_size in input_sizes]
				print('No of Inputs\t\tTime Taken'				)
				for input_size, runtime in zip(SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__				):
								print(SCREAMING_SNAKE_CASE__   ,      '\t\t'   ,      SCREAMING_SNAKE_CASE__				)
				plt.plot(SCREAMING_SNAKE_CASE__   ,      SCREAMING_SNAKE_CASE__				)
				plt.xlabel('Number of Inputs'				)
				plt.ylabel('Time taken in seconds'				)
				plt.show()


if __name__ == "__main__":
					from doctest import testmod

					testmod()




import numpy as np

from transformers import Pipeline
def 						_snake_case(   SCREAMING_SNAKE_CASE__      :     int				)							->				int:





    '''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						(							_UpperCAmelCase			):







    """simple docstring"""





    def 						snake_case__					(				self			:	Dict,**lowercase_			:	Tuple		)->   Tuple:





        '''simple docstring'''







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


    def 						snake_case__					(				self			:	List[Any],lowercase_			:	int,lowercase_			:	Optional[int]=None		)->   List[str]:





        '''simple docstring'''







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


    def 						snake_case__					(				self			:	str,lowercase_			:	Dict		)->   List[str]:





        '''simple docstring'''







        return self.model(**lowercase_		)


    def 						snake_case__					(				self			:	Dict,lowercase_			:	Optional[int]		)->   Dict:





        '''simple docstring'''







        A__   				=       model_outputs.logits[0].numpy()
        A__   				=       softmax(lowercase_		)

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

