
"""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'''


						_lowerCamelCase:     Dict   =     MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING


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


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]	,A_  :   Optional[int]	,A_  :   Optional[Any]   )  -> int:
							for example in examples:
								A     = video_classifier(A_   )

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


						@require_torch
						def     _SCREAMING_SNAKE_CASE   (			self  :   Any   )  -> Optional[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=A_	,feature_extractor=A_	,frame_sampling_rate=4   )

							A     = hf_hub_download(repo_id='nateraw/video-demo'	,filename='archery.mp4'	,repo_type='dataset'   )
							A     = video_classifier(A_	,top_k=2   )
							self.assertEqual(
							    nested_simplify(A_	,decimals=4   )	,[{'score': 0.51_99, 'label': 'LABEL_0'}, {'score': 0.48_01, 'label': 'LABEL_1'}]	,)

							A     = video_classifier(
							    [
							        video_file_path,
							        video_file_path,
							    ]	,top_k=2	,)
							self.assertEqual(
							    nested_simplify(A_	,decimals=4   )	,[
							        [{'score': 0.51_99, 'label': 'LABEL_0'}, {'score': 0.48_01, 'label': 'LABEL_1'}],
							        [{'score': 0.51_99, 'label': 'LABEL_0'}, {'score': 0.48_01, 'label': 'LABEL_1'}],
							    ]	,)




						@require_tf
						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]   )  -> Dict:
							pass

"""simple docstring"""


from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase				 =					{
    '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''],
    '''feature_extraction_mctct''': ['''MCTCTFeatureExtractor'''],
    '''processing_mctct''': ['''MCTCTProcessor'''],
}


try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase				 =					[
		    '''MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''MCTCTForCTC''',
		    '''MCTCTModel''',
		    '''MCTCTPreTrainedModel''',
		]


if TYPE_CHECKING:
		from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
		from .feature_extraction_mctct import MCTCTFeatureExtractor
		from .processing_mctct import MCTCTProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
		import sys

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