





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

snake_case_           =      logging.get_logger(__name__)

@add_end_docstrings(_UpperCAmelCase  )
class 		SCREAMING_SNAKE_CASE__    (	_UpperCAmelCase  ):


      def __init__(self	:				str    ,      **a__	:				Union[str, Any]				):





         """simple docstring"""



         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	:				Optional[int]    ,      a__	:				Union[str, List[str], "Image", List["Image"]]    ,      **a__	:				Union[str, Any]				):





         """simple docstring"""



         return super().__call__(a__    ,      **a__				)


      def        a			(self	:				Dict    ,      **a__	:				Any				):





         """simple docstring"""



         __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        a			(self	:				Tuple    ,      a__	:				List[str]    ,      a__	:				Union[str, Any]=None    ,      a__	:				Optional[Any]="This is a photo of {}."				):





         """simple docstring"""



         __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        a			(self	:				int    ,      a__	:				Any				):





         """simple docstring"""



         __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        a			(self	:				List[str]    ,      a__	:				Tuple				):





         """simple docstring"""



         __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 __future__ import annotations

snake_case_           =      [True] * 1000001
snake_case_           =      2
while i * i <= 1000000:
    if seive[i]:
        for j in range(i * i, 1000001, i):
            snake_case_           =      False
    i += 1






def lowerCamelCase__   (							snake_case_     :  int	)				->    bool:
   return seive[n]






def lowerCamelCase__   (							snake_case_     :  int	)				->    bool:
   return any(digit in '''02468''' for digit in str(snake_case_	)	)






def lowerCamelCase__   (							snake_case_     :  int = 100_0000	)				->    list[int]:
   __snake_case								=       [2]  # result already includes the number 2.
   for num in range(3	,				limit + 1	,				2	):
      if is_prime(snake_case_	) and not contains_an_even_digit(snake_case_	):
         __snake_case								=       str(snake_case_	)
         __snake_case								=       [int(str_num[j:] + str_num[:j]	) for j in range(len(snake_case_	)	)]
         if all(is_prime(snake_case_	) for i in list_nums	):
            result.append(snake_case_	)
   return result






def lowerCamelCase__   (							)				->    int:
   return len(find_circular_primes()	)


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

