
"""simple docstring"""



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

__lowercase						:     Dict							      =		logging.get_logger(__name__)





@add_end_docstrings(SCREAMING_SNAKE_CASE_					)
class 					lowerCAmelCase			(				SCREAMING_SNAKE_CASE_					):
     """simple docstring"""







     def __init__(      self ,		*UpperCamelCase__ ,		**UpperCamelCase__							)					->  List[Any]:







            '''simple docstring'''





            super().__init__(*snake_case__ ,		**snake_case__							)
            requires_backends(self ,		'''decord'''							)
            self.check_model_type(snake_case__							)




     def    _lowerCAmelCase		(      self ,		UpperCamelCase__=None ,		UpperCamelCase__=None ,		UpperCamelCase__=None							)					->  Any:







            '''simple docstring'''





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

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




     def __call__(      self ,		UpperCamelCase__ ,		**UpperCamelCase__							)					->  Dict:







            '''simple docstring'''





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




     def    _lowerCAmelCase		(      self ,		UpperCamelCase__ ,		UpperCamelCase__=None ,		UpperCamelCase__=1							)					->  int:







            '''simple docstring'''





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

            if video.startswith('''http://'''							) or video.startswith('''https://'''							):
                   lowerCamelCase_       							=		BytesIO(requests.get(snake_case__							).content							)

            lowerCamelCase_       							=		VideoReader(snake_case__							)
            videoreader.seek(0							)

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

            lowerCamelCase_       							=		videoreader.get_batch(snake_case__							).asnumpy()
            lowerCamelCase_       							=		list(snake_case__							)

            lowerCamelCase_       							=		self.image_processor(snake_case__ ,		return_tensors=self.framework							)
            return model_inputs




     def    _lowerCAmelCase		(      self ,		UpperCamelCase__							)					->  Tuple:







            '''simple docstring'''





            lowerCamelCase_       							=		self.model(**snake_case__							)
            return model_outputs




     def    _lowerCAmelCase		(      self ,		UpperCamelCase__ ,		UpperCamelCase__=5							)					->  str:







            '''simple docstring'''





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

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

            lowerCamelCase_       							=		scores.tolist()
            lowerCamelCase_       							=		ids.tolist()
            return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(snake_case__ ,		snake_case__							)]
def 	lowerCamelCase					(	UpperCamelCase     :				int							)   ->    bool:
		_lowerCamelCase				   =  (1 + 24 * n) ** 0.5
		return ((1 + root) / 6) % 1 == 0


def 	lowerCamelCase					(	UpperCamelCase     :				int = 50_00							)   ->    int:
		_lowerCamelCase				   =  [(i * (3 * i - 1)) // 2 for i in range(1			,       UpperCamelCase							)]
		for i, pentagonal_i in enumerate(UpperCamelCase							):
				for j in range(UpperCamelCase			,       len(UpperCamelCase							)							):
						_lowerCamelCase				   =  pentagonal_nums[j]
						_lowerCamelCase				   =  pentagonal_i + pentagonal_j
						_lowerCamelCase				   =  pentagonal_j - pentagonal_i
						if is_pentagonal(UpperCamelCase							) and is_pentagonal(UpperCamelCase							):
								return b

		return -1


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