





'''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 __a (   unittest.TestCase			):
   __UpperCamelCase   : int	      =	MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING





   def      UpperCAmelCase__     (					self				:			List[Any]				,lowerCamelCase				:			List[str]				,lowerCamelCase				:			str				,lowerCamelCase				:			int    ):

      '''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      UpperCAmelCase__     (					self				:			str				,lowerCamelCase				:			Optional[Any]				,lowerCamelCase				:			Optional[int]    ):

      '''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      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''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.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """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.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}],
              [{"""score""": 0.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}],
          ]				,)





   @require_tf
   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

      pass












'''simple docstring'''

def 						__magic_name__       (							__UpperCAmelCase = 1							,	__UpperCAmelCase = 1000      )						->					int:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       1
   __SCREAMING_SNAKE_CASE      							=       0

   for divide_by_number in range(__UpperCAmelCase							,	digit + 1      ):
      __SCREAMING_SNAKE_CASE      							=       []
      __SCREAMING_SNAKE_CASE      							=       numerator
      for _ in range(1							,	digit + 1      ):
         if now_divide in has_been_divided:
            if longest_list_length < len(__UpperCAmelCase      ):
               __SCREAMING_SNAKE_CASE      							=       len(__UpperCAmelCase      )
               __SCREAMING_SNAKE_CASE      							=       divide_by_number
         else:
            has_been_divided.append(__UpperCAmelCase      )
            __SCREAMING_SNAKE_CASE      							=       now_divide * 10 % divide_by_number

   return the_digit


# Tests
if __name__ == "__main__":
    import doctest

    doctest.testmod()





