

from io import BytesIO
from typing import List, Union

import requests

from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_decord_available():
	import numpy as np
	from decord import VideoReader


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

lowerCAmelCase__	   = logging.get_logger(__name__)

@add_end_docstrings(snake_case			)
class 					a__						(					snake_case			):
			"""simple docstring"""







			def __init__(    self      ,      *lowercase      ,      **lowercase       )  ->						int:
							'''simple docstring'''






							super().__init__(*lowercase      ,      **lowercase       )
							requires_backends(self      ,      "decord"       )
							self.check_model_type(lowercase       )


			def      UpperCamelCase		(    self      ,      lowercase=None      ,      lowercase=None      ,      lowercase=None       )  ->						Optional[Any]:
							'''simple docstring'''






							A__        =			{}
							if frame_sampling_rate is not None:
											A__        =			frame_sampling_rate
							if num_frames is not None:
											A__        =			num_frames

							A__        =			{}
							if top_k is not None:
											A__        =			top_k
							return preprocess_params, {}, postprocess_params


			def __call__(    self      ,      lowercase      ,      **lowercase       )  ->						Union[str, Any]:
							'''simple docstring'''






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


			def      UpperCamelCase		(    self      ,      lowercase      ,      lowercase=None      ,      lowercase=1       )  ->						int:
							'''simple docstring'''






							if num_frames is None:
											A__        =			self.model.config.num_frames

							if video.startswith("http://"       ) or video.startswith("https://"       ):
											A__        =			BytesIO(requests.get(lowercase       ).content       )

							A__        =			VideoReader(lowercase       )
							videoreader.seek(0       )

							A__        =			0
							A__        =			num_frames * frame_sampling_rate - 1
							A__        =			np.linspace(lowercase      ,      lowercase      ,      num=lowercase      ,      dtype=np.intaa       )

							A__        =			videoreader.get_batch(lowercase       ).asnumpy()
							A__        =			list(lowercase       )

							A__        =			self.image_processor(lowercase      ,      return_tensors=self.framework       )
							return model_inputs


			def      UpperCamelCase		(    self      ,      lowercase       )  ->						List[str]:
							'''simple docstring'''






							A__        =			self.model(**lowercase       )
							return model_outputs


			def      UpperCamelCase		(    self      ,      lowercase      ,      lowercase=5       )  ->						Tuple:
							'''simple docstring'''






							if top_k > self.model.config.num_labels:
											A__        =			self.model.config.num_labels

							if self.framework == "pt":
											A__        =			model_outputs.logits.softmax(-1       )[0]
											A__    ,				A__        =			probs.topk(lowercase       )
							else:
											raise ValueError(F'Unsupported framework: {self.framework}'       )

							A__        =			scores.tolist()
							A__        =			ids.tolist()
							return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(lowercase      ,      lowercase       )]




from math import factorial



def 					lowerCAmelCase__							(	SCREAMING_SNAKE_CASE_:							int = 1_0_0      )			->      int:




				'''simple docstring'''





				return sum(map(SCREAMING_SNAKE_CASE_	,       str(factorial(SCREAMING_SNAKE_CASE_      )      )      )      )


if __name__ == "__main__":
	print(solution(int(input("""Enter the Number: """).strip())))

