




from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase__					:  List[Any]      							=				logging.get_logger(__name__)

lowerCamelCase__					:  Optional[Any]      							=				{
    'hustvl/yolos-small': 'https://huggingface.co/hustvl/yolos-small/resolve/main/config.json',
    # See all YOLOS models at https://huggingface.co/models?filter=yolos
}





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 lowercase_							       =       "yolos"



 def __init__(				self    :						int							,							_lowerCAmelCase    :						Any=768							,							_lowerCAmelCase    :						Optional[Any]=12							,							_lowerCAmelCase    :						Any=12							,							_lowerCAmelCase    :						List[str]=3_072							,							_lowerCAmelCase    :						List[Any]="gelu"							,							_lowerCAmelCase    :						Optional[int]=0.0							,							_lowerCAmelCase    :						List[Any]=0.0							,							_lowerCAmelCase    :						Union[str, Any]=0.02							,							_lowerCAmelCase    :						Optional[int]=1E-12							,							_lowerCAmelCase    :						List[str]=[512, 864]							,							_lowerCAmelCase    :						Optional[Any]=16							,							_lowerCAmelCase    :						List[str]=3							,							_lowerCAmelCase    :						str=True							,							_lowerCAmelCase    :						int=100							,							_lowerCAmelCase    :						int=True							,							_lowerCAmelCase    :						Any=False							,							_lowerCAmelCase    :						List[Any]=1							,							_lowerCAmelCase    :						Union[str, Any]=5							,							_lowerCAmelCase    :						Optional[Any]=2							,							_lowerCAmelCase    :						List[Any]=5							,							_lowerCAmelCase    :						int=2							,							_lowerCAmelCase    :						int=0.1							,							**_lowerCAmelCase    :						Dict							,							):
       super().__init__(**_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_      		=     hidden_size
       SCREAMING_SNAKE_CASE_      		=     num_hidden_layers
       SCREAMING_SNAKE_CASE_      		=     num_attention_heads
       SCREAMING_SNAKE_CASE_      		=     intermediate_size
       SCREAMING_SNAKE_CASE_      		=     hidden_act
       SCREAMING_SNAKE_CASE_      		=     hidden_dropout_prob
       SCREAMING_SNAKE_CASE_      		=     attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE_      		=     initializer_range
       SCREAMING_SNAKE_CASE_      		=     layer_norm_eps
       SCREAMING_SNAKE_CASE_      		=     image_size
       SCREAMING_SNAKE_CASE_      		=     patch_size
       SCREAMING_SNAKE_CASE_      		=     num_channels
       SCREAMING_SNAKE_CASE_      		=     qkv_bias
       SCREAMING_SNAKE_CASE_      		=     num_detection_tokens
       SCREAMING_SNAKE_CASE_      		=     use_mid_position_embeddings
       SCREAMING_SNAKE_CASE_      		=     auxiliary_loss
       # Hungarian matcher
       SCREAMING_SNAKE_CASE_      		=     class_cost
       SCREAMING_SNAKE_CASE_      		=     bbox_cost
       SCREAMING_SNAKE_CASE_      		=     giou_cost
       # Loss coefficients
       SCREAMING_SNAKE_CASE_      		=     bbox_loss_coefficient
       SCREAMING_SNAKE_CASE_      		=     giou_loss_coefficient
       SCREAMING_SNAKE_CASE_      		=     eos_coefficient





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 lowercase_							       =       version.parse("1.11"   )



 @property
 def  lowerCAmelCase_    (				self    :						List[Any]		):
       return OrderedDict(
           [
               ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
           ]		)



 @property
 def  lowerCAmelCase_    (				self    :						Tuple		):
       return 1E-4




 @property
 def  lowerCAmelCase_    (				self    :						List[str]		):
       return 12






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




