


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 					__magic_name__		(			unittest.TestCase     ):
       __A			:      Dict        =   MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING






       def  __snake_case						(   self  :    Dict  ,     snake_case__  :    int  ,     snake_case__  :    Any  ,     snake_case__  :    int				):

              '''simple docstring'''






              lowercase		:Optional[Any]       							=				hf_hub_download(
                  repo_id='''nateraw/video-demo'''  ,     filename='''archery.mp4'''  ,     repo_type='''dataset'''				)
              lowercase		:Union[str, Any]       							=				VideoClassificationPipeline(model=_lowercase  ,     image_processor=_lowercase  ,     top_k=2				)
              lowercase		:Tuple       							=				[
                  example_video_filepath,
                  '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
              ]
              return video_classifier, examples






       def  __snake_case						(   self  :    Tuple  ,     snake_case__  :    Union[str, Any]  ,     snake_case__  :    List[Any]				):

              '''simple docstring'''






              for example in examples:
                     lowercase		:Optional[Any]       							=				video_classifier(_lowercase				)

                     self.assertEqual(
                         _lowercase  ,     [
                             {'''score''': ANY(_lowercase				), '''label''': ANY(_lowercase				)},
                             {'''score''': ANY(_lowercase				), '''label''': ANY(_lowercase				)},
                         ]  ,     )






       @require_torch
       def  __snake_case						(   self  :    str				):

              '''simple docstring'''






              lowercase		:Any       							=				'''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
              lowercase		:List[Any]       							=				VideoMAEFeatureExtractor(
                  size={'''shortest_edge''': 1_0}  ,     crop_size={'''height''': 1_0, '''width''': 1_0}				)
              lowercase		:Optional[Any]       							=				pipeline(
                  '''video-classification'''  ,     model=_lowercase  ,     feature_extractor=_lowercase  ,     frame_sampling_rate=4				)

              lowercase		:Dict       							=				hf_hub_download(repo_id='''nateraw/video-demo'''  ,     filename='''archery.mp4'''  ,     repo_type='''dataset'''				)
              lowercase		:List[Any]       							=				video_classifier(_lowercase  ,     top_k=2				)
              self.assertEqual(
                  nested_simplify(_lowercase  ,     decimals=4				)  ,     [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}]  ,     )

              lowercase		:List[Any]       							=				video_classifier(
                  [
                      video_file_path,
                      video_file_path,
                  ]  ,     top_k=2  ,     )
              self.assertEqual(
                  nested_simplify(_lowercase  ,     decimals=4				)  ,     [
                      [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}],
                      [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}],
                  ]  ,     )







       @require_tf
       def  __snake_case						(   self  :    Dict				):

              '''simple docstring'''






              pass





"""simple docstring"""



def       lowerCamelCase					(a_						:int)     ->							str:
       if number > 0:
              raise ValueError('''input must be a negative integer''')
       lowercase		:Any       							=				len(bin(a_)[3:])
       lowercase		:Any       							=				bin(abs(a_) - (1 << binary_number_length))[3:]
       lowercase		:Tuple       							=				(
           (
               '''1'''
               + '''0''' * (binary_number_length - len(a_))
               + twos_complement_number
           )
           if number < 0
           else '''0'''
       )
       return "0b" + twos_complement_number


if __name__ == "__main__":
 import doctest

 doctest.testmod()

