


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   __lowercase				(  unittest.TestCase  ):
  UpperCamelCase								=       MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING





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






     """simple docstring"""







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





  def        _lowercase				(		self						:					Optional[int]					,       __lowerCamelCase						:					List[Any]					,       __lowerCamelCase						:					Tuple       )    ->   List[Any]:






     """simple docstring"""







     for example in examples:
        UpperCAmelCase							=     video_classifier(lowerCamelCase__       )

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





  @require_torch
  def        _lowercase				(		self						:					Any       )    ->   List[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=lowerCamelCase__					,       feature_extractor=lowerCamelCase__					,       frame_sampling_rate=4       )

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

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






     """simple docstring"""







     pass







from math import isqrt
def   _UpperCamelCase				(						lowerCAmelCase_   )						->bool:
   return all(number % divisor != 0 for divisor in range(2  ,						isqrt(lowerCAmelCase_   ) + 1   )   )
def   _UpperCamelCase				(						lowerCAmelCase_ = 1_0**6   )						->int:
   UpperCAmelCase							=     0
   UpperCAmelCase							=     1
   UpperCAmelCase							=     7
   while prime_candidate < max_prime:
      primes_count += is_prime(lowerCAmelCase_   )

      cube_index += 1
      prime_candidate += 6 * cube_index

   return primes_count


if __name__ == "__main__":
 print(F"""{solution() = }""")



