





from typing import TYPE_CHECKING

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


UpperCamelCase__           =			{
    "configuration_distilbert": [
        "DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "DistilBertConfig",
        "DistilBertOnnxConfig",
    ],
    "tokenization_distilbert": ["DistilBertTokenizer"],
}

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCamelCase__           =			["DistilBertTokenizerFast"]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCamelCase__           =			[
					    "DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "DistilBertForMaskedLM",
					    "DistilBertForMultipleChoice",
					    "DistilBertForQuestionAnswering",
					    "DistilBertForSequenceClassification",
					    "DistilBertForTokenClassification",
					    "DistilBertModel",
					    "DistilBertPreTrainedModel",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCamelCase__           =			[
					    "TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TFDistilBertForMaskedLM",
					    "TFDistilBertForMultipleChoice",
					    "TFDistilBertForQuestionAnswering",
					    "TFDistilBertForSequenceClassification",
					    "TFDistilBertForTokenClassification",
					    "TFDistilBertMainLayer",
					    "TFDistilBertModel",
					    "TFDistilBertPreTrainedModel",
					]

try:
					if not is_flax_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCamelCase__           =			[
					    "FlaxDistilBertForMaskedLM",
					    "FlaxDistilBertForMultipleChoice",
					    "FlaxDistilBertForQuestionAnswering",
					    "FlaxDistilBertForSequenceClassification",
					    "FlaxDistilBertForTokenClassification",
					    "FlaxDistilBertModel",
					    "FlaxDistilBertPreTrainedModel",
					]


if TYPE_CHECKING:
					from .configuration_distilbert import (
					    DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    DistilBertConfig,
					    DistilBertOnnxConfig,
					)
					from .tokenization_distilbert import DistilBertTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_distilbert_fast import DistilBertTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_distilbert import (
										    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    DistilBertForMaskedLM,
										    DistilBertForMultipleChoice,
										    DistilBertForQuestionAnswering,
										    DistilBertForSequenceClassification,
										    DistilBertForTokenClassification,
										    DistilBertModel,
										    DistilBertPreTrainedModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_distilbert import (
										    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFDistilBertForMaskedLM,
										    TFDistilBertForMultipleChoice,
										    TFDistilBertForQuestionAnswering,
										    TFDistilBertForSequenceClassification,
										    TFDistilBertForTokenClassification,
										    TFDistilBertMainLayer,
										    TFDistilBertModel,
										    TFDistilBertPreTrainedModel,
										)

					try:
										if not is_flax_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_flax_distilbert import (
										    FlaxDistilBertForMaskedLM,
										    FlaxDistilBertForMultipleChoice,
										    FlaxDistilBertForQuestionAnswering,
										    FlaxDistilBertForSequenceClassification,
										    FlaxDistilBertForTokenClassification,
										    FlaxDistilBertModel,
										    FlaxDistilBertPreTrainedModel,
										)

else:
					import sys

					UpperCamelCase__           =			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)











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  :   List[str]      =							MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING






							def 					_lowerCamelCase		(    self	,			__lowerCAmelCase	,			__lowerCAmelCase	,			__lowerCAmelCase	):
														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 					_lowerCamelCase		(    self	,			__lowerCAmelCase	,			__lowerCAmelCase	):
														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 					_lowerCamelCase		(    self	):
														UpperCamelCase__					  =      """hf-internal-testing/tiny-random-VideoMAEForVideoClassification"""
														UpperCamelCase__					  =      VideoMAEFeatureExtractor(
														    size={"""shortest_edge""": 10}	,			crop_size={"""height""": 10, """width""": 10}	)
														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.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}]	,			)

														UpperCamelCase__					  =      video_classifier(
														    [
														        video_file_path,
														        video_file_path,
														    ]	,			top_k=2	,			)
														self.assertEqual(
														    nested_simplify(__lowerCAmelCase	,			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 					_lowerCamelCase		(    self	):
														pass




