


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

lowerCamelCase__							:						Tuple							     =   logging.get_logger(__name__)
@add_end_docstrings(lowercase_				)
class 		__magic_name__						(lowercase_				):





     '''simple docstring'''



     def __init__(					self:Any     ,		**_a:str   ):
       super().__init__(**_a   )

       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:Tuple     ,		_a:List[str]     ,		**_a:str   ):
       return super().__call__(_a     ,		**_a   )

     def 	SCREAMING_SNAKE_CASE__						(					self:List[Any]     ,		**_a:Optional[int]   ):
       snake_case__						= {}
       if "candidate_labels" in kwargs:
         snake_case__						= kwargs['''candidate_labels''']
       if "hypothesis_template" in kwargs:
         snake_case__						= kwargs['''hypothesis_template''']

       return preprocess_params, {}, {}

     def 	SCREAMING_SNAKE_CASE__						(					self:Union[str, Any]     ,		_a:str     ,		_a:Optional[Any]=None     ,		_a:str="This is a photo of {}."   ):
       snake_case__						= load_image(_a   )
       snake_case__						= self.image_processor(images=[image]     ,		return_tensors=self.framework   )
       snake_case__						= candidate_labels
       snake_case__						= [hypothesis_template.format(_a   ) for x in candidate_labels]
       snake_case__						= self.tokenizer(_a     ,		return_tensors=self.framework     ,		padding=_a   )
       snake_case__						= [text_inputs]
       return inputs

     def 	SCREAMING_SNAKE_CASE__						(					self:Optional[Any]     ,		_a:List[Any]   ):
       snake_case__						= model_inputs.pop('''candidate_labels'''   )
       snake_case__						= model_inputs.pop('''text_inputs'''   )
       if isinstance(text_inputs[0]     ,		_a   ):
         snake_case__						= text_inputs[0]
       else:
         # Batching case.
         snake_case__						= text_inputs[0][0]

       snake_case__						= self.model(**_a     ,		**_a   )

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







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

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




from math import sqrt





def    __lowerCamelCase      (					UpperCamelCase__ ):







							'''simple docstring'''






							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or number % 2 == 0 or number % 3 == 0:
														# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
														return False

							# All primes number are in format of 6k +/- 1
							for i in range(5  ,				int(sqrt(UpperCamelCase__ ) + 1 )  ,				6 ):
														if number % i == 0 or number % (i + 2) == 0:
																					return False
							return True





def    __lowerCamelCase      (					UpperCamelCase__ = 10001 ):







							'''simple docstring'''






							snake_case_     							=       0
							snake_case_     							=       1
							while count != nth and number < 3:
														number += 1
														if is_prime(UpperCamelCase__ ):
																					count += 1
							while count != nth:
														number += 2
														if is_prime(UpperCamelCase__ ):
																					count += 1
							return number


if __name__ == "__main__":
					print(F'''{solution() = }''')




