


'''simple docstring'''


import unittest

from huggingface_hub import hf_hub_download

from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
from transformers.pipelines import VideoClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_decord,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
)

from .test_pipelines_common import ANY






@is_pipeline_test
@require_torch_or_tf
@require_vision
@require_decord
class 	lowerCAmelCase__			(			unittest.TestCase	):
			lowerCAmelCase :	Any          =     MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING




			def 							lowerCAmelCase__    (		self  :     Tuple	,  lowerCamelCase__  :     List[Any]	,  lowerCamelCase__  :     Union[str, Any]	,  lowerCamelCase__  :     List[Any] )   ->Optional[Any]:



					'''simple docstring'''







					_UpperCAmelCase		:       Optional[Any]								=      hf_hub_download(
					    repo_id="nateraw/video-demo"	,  filename="archery.mp4"	,  repo_type="dataset" )
					_UpperCAmelCase		:       List[Any]								=      VideoClassificationPipeline(model=lowerCamelCase__	,  image_processor=lowerCamelCase__	,  top_k=2 )
					_UpperCAmelCase		:       Any								=      [
					    example_video_filepath,
					    "https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4",
					]
					return video_classifier, examples




			def 							lowerCAmelCase__    (		self  :     Optional[int]	,  lowerCamelCase__  :     List[Any]	,  lowerCamelCase__  :     Tuple )   ->List[Any]:



					'''simple docstring'''







					for example in examples:
							_UpperCAmelCase		:       Optional[int]								=      video_classifier(lowerCamelCase__ )

							self.assertEqual(
							    lowerCamelCase__	,  [
							        {"score": ANY(lowerCamelCase__ ), "label": ANY(lowerCamelCase__ )},
							        {"score": ANY(lowerCamelCase__ ), "label": ANY(lowerCamelCase__ )},
							    ]	,  )




			@require_torch
			def 							lowerCAmelCase__    (		self  :     Any )   ->List[Any]:



					'''simple docstring'''







					_UpperCAmelCase		:       Union[str, Any]								=      "hf-internal-testing/tiny-random-VideoMAEForVideoClassification"
					_UpperCAmelCase		:       List[str]								=      VideoMAEFeatureExtractor(
					    size={"shortest_edge": 10}	,  crop_size={"height": 10, "width": 10} )
					_UpperCAmelCase		:       List[Any]								=      pipeline(
					    "video-classification"	,  model=lowerCamelCase__	,  feature_extractor=lowerCamelCase__	,  frame_sampling_rate=4 )

					_UpperCAmelCase		:       List[str]								=      hf_hub_download(repo_id="nateraw/video-demo"	,  filename="archery.mp4"	,  repo_type="dataset" )
					_UpperCAmelCase		:       Union[str, Any]								=      video_classifier(lowerCamelCase__	,  top_k=2 )
					self.assertEqual(
					    nested_simplify(lowerCamelCase__	,  decimals=4 )	,  [{"score": 0.5_1_9_9, "label": "LABEL_0"}, {"score": 0.4_8_0_1, "label": "LABEL_1"}]	,  )

					_UpperCAmelCase		:       Any								=      video_classifier(
					    [
					        video_file_path,
					        video_file_path,
					    ]	,  top_k=2	,  )
					self.assertEqual(
					    nested_simplify(lowerCamelCase__	,  decimals=4 )	,  [
					        [{"score": 0.5_1_9_9, "label": "LABEL_0"}, {"score": 0.4_8_0_1, "label": "LABEL_1"}],
					        [{"score": 0.5_1_9_9, "label": "LABEL_0"}, {"score": 0.4_8_0_1, "label": "LABEL_1"}],
					    ]	,  )






			@require_tf
			def 							lowerCAmelCase__    (		self  :     List[str] )   ->Optional[int]:



					'''simple docstring'''







					pass







'''simple docstring'''


import os






def  __lowerCAmelCase ():
		_UpperCAmelCase		:       List[Any]								=      os.path.join(os.path.dirname(__lowerCAmelCase   )      , "num.txt"   )
		with open(__lowerCAmelCase   ) as file_hand:
				return str(sum(int(__lowerCAmelCase   ) for line in file_hand   )   )[:10]


if __name__ == "__main__":
						print(solution())



