


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

     '''simple docstring'''
     A_       :	str    =		MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING


     def 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Union[str, Any]:
          _a    	=				hf_hub_download(
              repo_id='''nateraw/video-demo'''    ,				filename='''archery.mp4'''    ,				repo_type='''dataset'''							)
          _a    	=				VideoClassificationPipeline(model=__UpperCAmelCase    ,				image_processor=__UpperCAmelCase    ,				top_k=2							)
          _a    	=				[
              example_video_filepath,
              '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
          ]
          return video_classifier, examples


     def 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Union[str, Any]:
          for example in examples:
               _a    	=				video_classifier(__UpperCAmelCase							)

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


     @require_torch
     def 							_UpperCAmelCase      (      self							)       ->							Any:
          _a    	=				'''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
          _a    	=				VideoMAEFeatureExtractor(
              size={'''shortest_edge''': 10}    ,				crop_size={'''height''': 10, '''width''': 10}							)
          _a    	=				pipeline(
              '''video-classification'''    ,				model=__UpperCAmelCase    ,				feature_extractor=__UpperCAmelCase    ,				frame_sampling_rate=4							)

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

          _a    	=				video_classifier(
              [
                  video_file_path,
                  video_file_path,
              ]    ,				top_k=2    ,				)
          self.assertEqual(
              nested_simplify(__UpperCAmelCase    ,				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 							_UpperCAmelCase      (      self							)       ->							Tuple:
          pass



"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


__snake_case		=       {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __snake_case		=       [
       '''VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''ViTMAEForPreTraining''',
       '''ViTMAELayer''',
       '''ViTMAEModel''',
       '''ViTMAEPreTrainedModel''',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __snake_case		=       [
       '''TFViTMAEForPreTraining''',
       '''TFViTMAEModel''',
       '''TFViTMAEPreTrainedModel''',
   ]

if TYPE_CHECKING:
   from .configuration_vit_mae import VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMAEConfig

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_vit_mae import (
          VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST,
          ViTMAEForPreTraining,
          ViTMAELayer,
          ViTMAEModel,
          ViTMAEPreTrainedModel,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_vit_mae import TFViTMAEForPreTraining, TFViTMAEModel, TFViTMAEPreTrainedModel


else:
   import sys

   __snake_case		=       _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)