






'''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			):
      snake_case_												=							MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING




      def        __magic_name__		( self		:							Tuple   , __lowercase		:							Tuple   , __lowercase		:							int   , __lowercase		:							Dict )		->  str:
            SCREAMING_SNAKE_CASE__       :			Any													=hf_hub_download(
                repo_id='''nateraw/video-demo'''   , filename='''archery.mp4'''   , repo_type='''dataset''' )
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=VideoClassificationPipeline(model=__lowercase   , image_processor=__lowercase   , top_k=2 )
            SCREAMING_SNAKE_CASE__       :			Dict													=[
                example_video_filepath,
                '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
            ]
            return video_classifier, examples




      def        __magic_name__		( self		:							Dict   , __lowercase		:							Tuple   , __lowercase		:							Any )		->  Any:
            for example in examples:
                  SCREAMING_SNAKE_CASE__       :			Optional[Any]													=video_classifier(__lowercase )

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




      @require_torch
      def        __magic_name__		( self		:							Optional[int] )		->  Optional[int]:
            SCREAMING_SNAKE_CASE__       :			Optional[int]													='''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
            SCREAMING_SNAKE_CASE__       :			Tuple													=VideoMAEFeatureExtractor(
                size={'''shortest_edge''': 10}   , crop_size={'''height''': 10, '''width''': 10} )
            SCREAMING_SNAKE_CASE__       :			Tuple													=pipeline(
                '''video-classification'''   , model=__lowercase   , feature_extractor=__lowercase   , frame_sampling_rate=4 )

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

            SCREAMING_SNAKE_CASE__       :			str													=video_classifier(
                [
                    video_file_path,
                    video_file_path,
                ]   , top_k=2   , )
            self.assertEqual(
                nested_simplify(__lowercase   , 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        __magic_name__		( self		:							Optional[Any] )		->  List[str]:
            pass







'''simple docstring'''
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


a_					=	{
    'configuration_instructblip': [
        'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'InstructBlipConfig',
        'InstructBlipQFormerConfig',
        'InstructBlipVisionConfig',
    ],
    'processing_instructblip': ['InstructBlipProcessor'],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  a_					=	[
      'INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST',
      'InstructBlipQFormerModel',
      'InstructBlipPreTrainedModel',
      'InstructBlipForConditionalGeneration',
      'InstructBlipVisionModel',
  ]

if TYPE_CHECKING:
  from .configuration_instructblip import (
      INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
      InstructBlipConfig,
      InstructBlipQFormerConfig,
      InstructBlipVisionConfig,
  )
  from .processing_instructblip import InstructBlipProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_instructblip import (
        INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
        InstructBlipForConditionalGeneration,
        InstructBlipPreTrainedModel,
        InstructBlipQFormerModel,
        InstructBlipVisionModel,
    )

else:
  import sys

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