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_tf_available():
					import tensorflow as tf

					from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
					from ..tf_utils import stable_softmax

if is_torch_available():
					from ..models.auto.modeling_auto import MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING

__UpperCamelCase		:       Tuple									=     logging.get_logger(__name__)





@add_end_docstrings(UpperCamelCase_)
class 					lowercase__						(   UpperCamelCase_):


						def __init__(       self	:				List[str]    ,		*UpperCamelCase__	:				Union[str, Any]    ,		**UpperCamelCase__	:				int						):





												'''simple docstring'''





												super().__init__(*UpperCamelCase__    ,		**UpperCamelCase__						)
												requires_backends(self    ,		'''vision'''						)
												self.check_model_type(
												    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
												    if self.framework == '''tf'''
												    else MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING						)


						def        __A       (       self	:				int    ,		UpperCamelCase__	:				List[Any]=None						):





												'''simple docstring'''





												SCREAMING_SNAKE_CASE							:    Optional[Any]							=							{}
												if top_k is not None:
																		SCREAMING_SNAKE_CASE							:    List[str]							=							top_k
												return {}, {}, postprocess_params


						def __call__(       self	:				List[str]    ,		UpperCamelCase__	:				Union[str, List[str], "Image.Image", List["Image.Image"]]    ,		**UpperCamelCase__	:				List[str]						):





												'''simple docstring'''





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


						def        __A       (       self	:				Optional[int]    ,		UpperCamelCase__	:				Union[str, Any]						):





												'''simple docstring'''





												SCREAMING_SNAKE_CASE							:    Any							=							load_image(UpperCamelCase__						)
												SCREAMING_SNAKE_CASE							:    List[str]							=							self.image_processor(images=UpperCamelCase__    ,		return_tensors=self.framework						)
												return model_inputs


						def        __A       (       self	:				Optional[Any]    ,		UpperCamelCase__	:				Optional[Any]						):





												'''simple docstring'''





												SCREAMING_SNAKE_CASE							:    int							=							self.model(**UpperCamelCase__						)
												return model_outputs



						def        __A       (       self	:				Any    ,		UpperCamelCase__	:				Optional[int]    ,		UpperCamelCase__	:				Union[str, Any]=5						):





												'''simple docstring'''





												if top_k > self.model.config.num_labels:
																		SCREAMING_SNAKE_CASE							:    Union[str, Any]							=							self.model.config.num_labels

												if self.framework == "pt":
																		SCREAMING_SNAKE_CASE							:    Optional[Any]							=							model_outputs.logits.softmax(-1						)[0]
																		SCREAMING_SNAKE_CASE				,  SCREAMING_SNAKE_CASE							:    str							=							probs.topk(UpperCamelCase__						)
												elif self.framework == "tf":
																		SCREAMING_SNAKE_CASE							:    Union[str, Any]							=							stable_softmax(model_outputs.logits    ,		axis=-1						)[0]
																		SCREAMING_SNAKE_CASE							:    Optional[int]							=							tf.math.top_k(UpperCamelCase__    ,		k=UpperCamelCase__						)
																		SCREAMING_SNAKE_CASE				,  SCREAMING_SNAKE_CASE							:    List[str]							=							topk.values.numpy(), topk.indices.numpy()
												else:
																		raise ValueError(f"""Unsupported framework: {self.framework}"""						)

												SCREAMING_SNAKE_CASE							:    Optional[int]							=							scores.tolist()
												SCREAMING_SNAKE_CASE							:    Optional[Any]							=							ids.tolist()
												return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(UpperCamelCase__    ,		UpperCamelCase__						)]






from math import ceil
def       A	(    _lowercase = 1_001						):
						SCREAMING_SNAKE_CASE							:    Any							=							1

						for i in range(1		,  int(ceil(n / 2.0						)						)						):
												SCREAMING_SNAKE_CASE							:    Union[str, Any]							=							2 * i + 1
												SCREAMING_SNAKE_CASE							:    int							=							2 * i
												SCREAMING_SNAKE_CASE							:    List[str]							=							total + 4 * odd**2 - 6 * even

						return total


if __name__ == "__main__":
					import sys

					if len(sys.argv) == 1:
										print(solution())
					else:
										try:
															__UpperCamelCase		:       Dict									=     int(sys.argv[1])
															print(solution(n))
										except ValueError:
															print('Invalid entry - please enter a number')





