'''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 		__A       (unittest.TestCase   ):
       snake_case       :int				    =					MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING






       def 			_snake_case						(      self				,     UpperCamelCase_				,     UpperCamelCase_				,     UpperCamelCase_      ):
              __UpperCAmelCase  :				Any       				=		hf_hub_download(
                  repo_id="nateraw/video-demo"				,     filename="archery.mp4"				,     repo_type="dataset"      )
              __UpperCAmelCase  :				Optional[Any]       				=		VideoClassificationPipeline(model=UpperCamelCase_				,     image_processor=UpperCamelCase_				,     top_k=2      )
              __UpperCAmelCase  :				Dict       				=		[
                  example_video_filepath,
                  "https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4",
              ]
              return video_classifier, examples






       def 			_snake_case						(      self				,     UpperCamelCase_				,     UpperCamelCase_      ):
              for example in examples:
                     __UpperCAmelCase  :				int       				=		video_classifier(UpperCamelCase_      )

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






       @require_torch
       def 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Union[str, Any]       				=		"hf-internal-testing/tiny-random-VideoMAEForVideoClassification"
              __UpperCAmelCase  :				Optional[Any]       				=		VideoMAEFeatureExtractor(
                  size={"shortest_edge": 10}				,     crop_size={"height": 10, "width": 10}      )
              __UpperCAmelCase  :				Optional[Any]       				=		pipeline(
                  "video-classification"				,     model=UpperCamelCase_				,     feature_extractor=UpperCamelCase_				,     frame_sampling_rate=4      )

              __UpperCAmelCase  :				Any       				=		hf_hub_download(repo_id="nateraw/video-demo"				,     filename="archery.mp4"				,     repo_type="dataset"      )
              __UpperCAmelCase  :				Dict       				=		video_classifier(UpperCamelCase_				,     top_k=2      )
              self.assertEqual(
                  nested_simplify(UpperCamelCase_				,     decimals=4      )				,     [{"score": 0.5_1_9_9, "label": "LABEL_0"}, {"score": 0.4_8_0_1, "label": "LABEL_1"}]				,     )

              __UpperCAmelCase  :				str       				=		video_classifier(
                  [
                      video_file_path,
                      video_file_path,
                  ]				,     top_k=2				,     )
              self.assertEqual(
                  nested_simplify(UpperCamelCase_				,     decimals=4      )				,     [
                      [{"score": 0.5_1_9_9, "label": "LABEL_0"}, {"score": 0.4_8_0_1, "label": "LABEL_1"}],
                      [{"score": 0.5_1_9_9, "label": "LABEL_0"}, {"score": 0.4_8_0_1, "label": "LABEL_1"}],
                  ]				,     )







       @require_tf
       def 			_snake_case						(      self      ):
              pass







'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


_a   :	Any 							=   logging.get_logger(__name__)

_a   :	List[Any] 							=   {
    "microsoft/cvt-13": "https://huggingface.co/microsoft/cvt-13/resolve/main/config.json",
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}






class 		__A       (__magic_name__   ):
       snake_case       :Any				    =					"cvt"






       def __init__(      self				,     UpperCamelCase_=3				,     UpperCamelCase_=[7, 3, 3]				,     UpperCamelCase_=[4, 2, 2]				,     UpperCamelCase_=[2, 1, 1]				,     UpperCamelCase_=[64, 1_92, 3_84]				,     UpperCamelCase_=[1, 3, 6]				,     UpperCamelCase_=[1, 2, 10]				,     UpperCamelCase_=[4.0, 4.0, 4.0]				,     UpperCamelCase_=[0.0, 0.0, 0.0]				,     UpperCamelCase_=[0.0, 0.0, 0.0]				,     UpperCamelCase_=[0.0, 0.0, 0.1]				,     UpperCamelCase_=[True, True, True]				,     UpperCamelCase_=[False, False, True]				,     UpperCamelCase_=["dw_bn", "dw_bn", "dw_bn"]				,     UpperCamelCase_=[3, 3, 3]				,     UpperCamelCase_=[1, 1, 1]				,     UpperCamelCase_=[2, 2, 2]				,     UpperCamelCase_=[1, 1, 1]				,     UpperCamelCase_=[1, 1, 1]				,     UpperCamelCase_=0.0_2				,     UpperCamelCase_=1E-12				,     **UpperCamelCase_				,     ):
              super().__init__(**UpperCamelCase_      )
              __UpperCAmelCase  :				Optional[int]       				=		num_channels
              __UpperCAmelCase  :				Optional[Any]       				=		patch_sizes
              __UpperCAmelCase  :				List[str]       				=		patch_stride
              __UpperCAmelCase  :				Tuple       				=		patch_padding
              __UpperCAmelCase  :				int       				=		embed_dim
              __UpperCAmelCase  :				str       				=		num_heads
              __UpperCAmelCase  :				Any       				=		depth
              __UpperCAmelCase  :				List[str]       				=		mlp_ratio
              __UpperCAmelCase  :				List[str]       				=		attention_drop_rate
              __UpperCAmelCase  :				Dict       				=		drop_rate
              __UpperCAmelCase  :				Dict       				=		drop_path_rate
              __UpperCAmelCase  :				str       				=		qkv_bias
              __UpperCAmelCase  :				Optional[int]       				=		cls_token
              __UpperCAmelCase  :				Optional[Any]       				=		qkv_projection_method
              __UpperCAmelCase  :				Tuple       				=		kernel_qkv
              __UpperCAmelCase  :				Optional[Any]       				=		padding_kv
              __UpperCAmelCase  :				Optional[int]       				=		stride_kv
              __UpperCAmelCase  :				Any       				=		padding_q
              __UpperCAmelCase  :				List[Any]       				=		stride_q
              __UpperCAmelCase  :				Union[str, Any]       				=		initializer_range
              __UpperCAmelCase  :				Any       				=		layer_norm_eps






