



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






    """simple docstring"""





    _SCREAMING_SNAKE_CASE	  =  MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING






    def  A       (  self      :					int  ,						UpperCamelCase__      :					int  ,						UpperCamelCase__      :					int  ,						UpperCamelCase__      :					Optional[int] ):


       """simple docstring"""







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






    def  A       (  self      :					str  ,						UpperCamelCase__      :					Union[str, Any]  ,						UpperCamelCase__      :					Any ):


       """simple docstring"""







       for example in examples:
          UpperCamelCase					=  video_classifier(UpperCamelCase__ )

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






    @require_torch
    def  A       (  self      :					Any ):


       """simple docstring"""







       UpperCamelCase					=  'hf-internal-testing/tiny-random-VideoMAEForVideoClassification'
       UpperCamelCase					=  VideoMAEFeatureExtractor(
           size={'shortest_edge': 1_0}  ,						crop_size={'height': 1_0, 'width': 1_0} )
       UpperCamelCase					=  pipeline(
           'video-classification'  ,						model=UpperCamelCase__  ,						feature_extractor=UpperCamelCase__  ,						frame_sampling_rate=4 )

       UpperCamelCase					=  hf_hub_download(repo_id='nateraw/video-demo'  ,						filename='archery.mp4'  ,						repo_type='dataset' )
       UpperCamelCase					=  video_classifier(UpperCamelCase__  ,						top_k=2 )
       self.assertEqual(
           nested_simplify(UpperCamelCase__  ,						decimals=4 )  ,						[{'score': 0.5_1_9_9, 'label': 'LABEL_0'}, {'score': 0.4_8_0_1, 'label': 'LABEL_1'}]  ,						)

       UpperCamelCase					=  video_classifier(
           [
               video_file_path,
               video_file_path,
           ]  ,						top_k=2  ,						)
       self.assertEqual(
           nested_simplify(UpperCamelCase__  ,						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[Any] ):


       """simple docstring"""







       pass




'''simple docstring'''



def    a__       (  a__						):




     """simple docstring"""


     if isinstance(a__      ,    a__						):
          raise TypeError("""'float' object cannot be interpreted as an integer"""						)
     if isinstance(a__      ,    a__						):
          raise TypeError("""'str' object cannot be interpreted as an integer"""						)

     if num == 0:
          return "0b0"

     __SCREAMING_SNAKE_CASE     =      False

     if num < 0:
          __SCREAMING_SNAKE_CASE     =      True
          __SCREAMING_SNAKE_CASE     =      -num

     __SCREAMING_SNAKE_CASE     =      []
     while num > 0:
          binary.insert(0      ,    num % 2						)
          num >>= 1

     if negative:
          return "-0b" + "".join(str(a__						) for e in binary						)

     return "0b" + "".join(str(a__						) for e in binary						)


if __name__ == "__main__":
  import doctest

  doctest.testmod()






