


"""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 snake_case      (  unittest.TestCase):
		__UpperCamelCase           =			MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING







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





						'''simple docstring'''







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







		def  a_ (					self      :       Optional[int]    ,   a__      :       List[Any]    ,   a__      :       Tuple		)       ->						List[Any]:





						'''simple docstring'''







						for example in examples:
										_A					  =			video_classifier(lowerCamelCase__		)

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







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





						'''simple docstring'''







						_A					  =			"hf-internal-testing/tiny-random-VideoMAEForVideoClassification"
						_A					  =			VideoMAEFeatureExtractor(
						    size={"shortest_edge": 10}    ,   crop_size={"height": 10, "width": 10}		)
						_A					  =			pipeline(
						    "video-classification"    ,   model=lowerCamelCase__    ,   feature_extractor=lowerCamelCase__    ,   frame_sampling_rate=4		)

						_A					  =			hf_hub_download(repo_id="nateraw/video-demo"    ,   filename="archery.mp4"    ,   repo_type="dataset"		)
						_A					  =			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"}]    ,   )

						_A					  =			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  a_ (					self      :       List[str]		)       ->						Optional[int]:





						'''simple docstring'''







						pass



"""simple docstring"""


import numpy as np






def      a__ (				__lowercase     ,			__lowercase   )	->	np.ndarray:
				return np.where(vector > 0     ,			__lowercase     ,			(alpha * (np.exp(__lowercase   ) - 1))   )


if __name__ == "__main__":
		import doctest

		doctest.testmod()