
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

UpperCamelCase_						=						logging.get_logger(__name__)

@add_end_docstrings(_UpperCAmelCase				)
class      _SCREAMING_SNAKE_CASE				(		_UpperCAmelCase				):





				def __init__(		self			:		List[Any]       ,   **snake_case_			:		Optional[int]				):


								"""simple docstring"""

								super().__init__(**SCREAMING_SNAKE_CASE_				)

								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			:		Union[str, Any]       ,   snake_case_			:		int       ,   **snake_case_			:		Union[str, Any]				):


								"""simple docstring"""

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





				def 							_UpperCAmelCase    (		self			:		Any       ,   **snake_case_			:		Optional[Any]				):


								"""simple docstring"""

								A  :	Dict				=					{}
								if "candidate_labels" in kwargs:
												A  :	List[str]				=					kwargs['candidate_labels']
								if "hypothesis_template" in kwargs:
												A  :	Tuple				=					kwargs['hypothesis_template']

								return preprocess_params, {}, {}





				def 							_UpperCAmelCase    (		self			:		List[Any]       ,   snake_case_			:		int       ,   snake_case_			:		Optional[int]=None       ,   snake_case_			:		Union[str, Any]="This is a photo of {}."				):


								"""simple docstring"""

								A  :	Union[str, Any]				=					load_image(SCREAMING_SNAKE_CASE_				)
								A  :	int				=					self.image_processor(images=[image]       ,   return_tensors=self.framework				)
								A  :	Optional[Any]				=					candidate_labels
								A  :	int				=					[hypothesis_template.format(SCREAMING_SNAKE_CASE_				) for x in candidate_labels]
								A  :	Union[str, Any]				=					self.tokenizer(SCREAMING_SNAKE_CASE_       ,   return_tensors=self.framework       ,   padding=SCREAMING_SNAKE_CASE_				)
								A  :	List[str]				=					[text_inputs]
								return inputs





				def 							_UpperCAmelCase    (		self			:		List[Any]       ,   snake_case_			:		List[Any]				):


								"""simple docstring"""

								A  :	Dict				=					model_inputs.pop('''candidate_labels'''				)
								A  :	int				=					model_inputs.pop('''text_inputs'''				)
								if isinstance(text_inputs[0]       ,   SCREAMING_SNAKE_CASE_				):
												A  :	List[Any]				=					text_inputs[0]
								else:
												# Batching case.
												A  :	Optional[Any]				=					text_inputs[0][0]

								A  :	Optional[int]				=					self.model(**SCREAMING_SNAKE_CASE_       ,   **SCREAMING_SNAKE_CASE_				)

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






				def 							_UpperCAmelCase    (		self			:		Optional[Any]       ,   snake_case_			:		List[str]				):


								"""simple docstring"""

								A  :	str				=					model_outputs.pop('''candidate_labels'''				)
								A  :	Union[str, Any]				=					model_outputs['logits'][0]
								if self.framework == "pt":
												A  :	List[Any]				=					logits.softmax(dim=-1				).squeeze(-1				)
												A  :	Dict				=					probs.tolist()
												if not isinstance(SCREAMING_SNAKE_CASE_       ,   SCREAMING_SNAKE_CASE_				):
																A  :	List[Any]				=					[scores]
								elif self.framework == "tf":
												A  :	Union[str, Any]				=					stable_softmax(SCREAMING_SNAKE_CASE_       ,   axis=-1				)
												A  :	Optional[Any]				=					probs.numpy().tolist()
								else:
												raise ValueError(f"""Unsupported framework: {self.framework}"""				)

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



'''simple docstring'''



def      UpperCAmelCase__   (      UpperCAmelCase_       :							int = 10_00				)	->						int:
     __lowerCamelCase  :      Union[str, Any]														=						3
     __lowerCamelCase  :      Dict														=						0
     while a < n:
          if a % 3 == 0 or a % 5 == 0:
               result += a
          elif a % 15 == 0:
               result -= a
          a += 1
     return result


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






