





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 		UpperCamelCase__			(				unittest.TestCase       ):



     '''simple docstring'''

     __snake_case   :     List[Any]		     =      MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING






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




           '''simple docstring'''


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






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple						,lowerCamelCase__						:   Any						,lowerCamelCase__						:   Union[str, Any]	)					->		str:




           '''simple docstring'''


           for example in examples:
                 SCREAMING_SNAKE_CASE		=						video_classifier(lowerCamelCase__	)

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






     @require_torch
     def     SCREAMING_SNAKE_CASE__  (							self						:   Any	)					->		Tuple:




           '''simple docstring'''


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

           SCREAMING_SNAKE_CASE		=						hf_hub_download(repo_id="""nateraw/video-demo"""						,filename="""archery.mp4"""						,repo_type="""dataset"""	)
           SCREAMING_SNAKE_CASE		=						video_classifier(lowerCamelCase__						,top_k=2	)
           self.assertEqual(
               nested_simplify(lowerCamelCase__						,decimals=4	)						,[{"""score""": 0.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}]						,)

           SCREAMING_SNAKE_CASE		=						video_classifier(
               [
                   video_file_path,
                   video_file_path,
               ]						,top_k=2						,)
           self.assertEqual(
               nested_simplify(lowerCamelCase__						,decimals=4	)						,[
                   [{"""score""": 0.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}],
                   [{"""score""": 0.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}],
               ]						,)






     @require_tf
     def     SCREAMING_SNAKE_CASE__  (							self						:   int	)					->		str:




           '''simple docstring'''


           pass









from __future__ import annotations



def        __lowercase       (				_SCREAMING_SNAKE_CASE     )			->       list[int]:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						2
      SCREAMING_SNAKE_CASE		=						[]
      while i * i <= n:
            if n % i:
                  i += 1
            else:
                  n //= i
                  factors.append(_SCREAMING_SNAKE_CASE     )
      if n > 1:
            factors.append(_SCREAMING_SNAKE_CASE     )
      return factors


if __name__ == "__main__":
      import doctest

      doctest.testmod()


