
"""simple docstring"""


from collections import UserDict
from typing import Union

import numpy as np
import requests

from ..utils import (
    add_end_docstrings,
    logging,
)
from .audio_classification import ffmpeg_read
from .base import PIPELINE_INIT_ARGS, Pipeline


_lowercase				 =					logging.get_logger(__name__)







@add_end_docstrings(_lowercase     )
class 					lowerCAmelCase_					(   _lowercase     ):



						'''simple docstring'''


						def __init__(			self  :   Optional[Any]	,**A_  :   Union[str, Any]   )  -> str:
							super().__init__(**A_   )

							if self.framework != "pt":
								raise ValueError(F'The {self.__class__} is only available in PyTorch.'   )
							# No specific FOR_XXX available yet


						def __call__(			self  :   Dict	,A_  :   Union[np.ndarray, bytes, str]	,**A_  :   List[Any]   )  -> List[str]:
							return super().__call__(A_	,**A_   )


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

							return preprocess_params, {}, {}


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]	,A_  :   List[str]	,A_  :   Tuple=None	,A_  :   Tuple="This is a sound of {}."   )  -> Union[str, Any]:
							if isinstance(A_	,A_   ):
								if audio.startswith('http://'   ) or audio.startswith('https://'   ):
									# We need to actually check for a real protocol, otherwise it's impossible to use a local file
									# like http_huggingface_co.png
									A     = requests.get(A_   ).content
								else:
									with open(A_	,'rb'   ) as f:
										A     = f.read()

							if isinstance(A_	,A_   ):
								A     = ffmpeg_read(A_	,self.feature_extractor.sampling_rate   )

							if not isinstance(A_	,np.ndarray   ):
								raise ValueError('We expect a numpy ndarray as input'   )
							if len(audio.shape   ) != 1:
								raise ValueError('We expect a single channel audio input for ZeroShotAudioClassificationPipeline'   )

							A     = self.feature_extractor(
							    [audio]	,sampling_rate=self.feature_extractor.sampling_rate	,return_tensors='pt'   )
							A     = candidate_labels
							A     = [hypothesis_template.format(A_   ) for x in candidate_labels]
							A     = self.tokenizer(A_	,return_tensors=self.framework	,padding=A_   )
							A     = [text_inputs]
							return inputs


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

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

							A     = {
							    'candidate_labels': candidate_labels,
							    'logits': outputs.logits_per_audio,
							}
							return model_outputs




						def     _SCREAMING_SNAKE_CASE   (			self  :   Any	,A_  :   Optional[Any]   )  -> int:
							A     = model_outputs.pop('candidate_labels'   )
							A     = model_outputs['logits'][0]

							if self.framework == "pt":
								A     = logits.softmax(dim=0   )
								A     = probs.tolist()
							else:
								raise ValueError('`tf` framework not supported.'   )

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

"""simple docstring"""


from maths.prime_check import is_prime






def    _snake_case					(		snake_case__ :  int  ):
	if not isinstance(snake_case__						,   snake_case__  ):
		A     = F'Input value of [number={number}] must be an integer'
		raise TypeError(snake_case__  )
	if is_prime(snake_case__  ) and is_prime(number + 2  ):
		return number + 2
	else:
		return -1


if __name__ == "__main__":
		import doctest

		doctest.testmod()