





"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCamelCase     :						Tuple						       =  logging.get_logger(__name__)

__UpperCamelCase     :						Optional[int]						       =  {
    '''facebook/s2t-small-librispeech-asr''': (
        '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}







class       a							(   _a  ):
 snake_case__             =       """speech_to_text"""
 snake_case__             =       ["""past_key_values"""]
 snake_case__             =       {"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}



 def __init__(     self				,       _snake_case=1_00_00				,       _snake_case=12				,       _snake_case=20_48				,       _snake_case=4				,       _snake_case=6				,       _snake_case=20_48				,       _snake_case=4				,       _snake_case=0.0				,       _snake_case=0.0				,       _snake_case=True				,       _snake_case=True				,       _snake_case="relu"				,       _snake_case=2_56				,       _snake_case=0.1				,       _snake_case=0.0				,       _snake_case=0.0				,       _snake_case=0.02				,       _snake_case=2				,       _snake_case=True				,       _snake_case=1				,       _snake_case=0				,       _snake_case=2				,       _snake_case=60_00				,       _snake_case=10_24				,       _snake_case=2				,       _snake_case=(5, 5)				,       _snake_case=10_24				,       _snake_case=80				,       _snake_case=1				,       **_snake_case				,       ):







  """simple docstring"""






  lowerCAmelCase    				= vocab_size
  lowerCAmelCase    				= d_model
  lowerCAmelCase    				= encoder_ffn_dim
  lowerCAmelCase    				= encoder_layers
  lowerCAmelCase    				= encoder_attention_heads
  lowerCAmelCase    				= decoder_ffn_dim
  lowerCAmelCase    				= decoder_layers
  lowerCAmelCase    				= decoder_attention_heads
  lowerCAmelCase    				= dropout
  lowerCAmelCase    				= attention_dropout
  lowerCAmelCase    				= activation_dropout
  lowerCAmelCase    				= activation_function
  lowerCAmelCase    				= init_std
  lowerCAmelCase    				= encoder_layerdrop
  lowerCAmelCase    				= decoder_layerdrop
  lowerCAmelCase    				= use_cache
  lowerCAmelCase    				= encoder_layers
  lowerCAmelCase    				= scale_embedding  # scale factor will be sqrt(d_model) if True
  lowerCAmelCase    				= max_source_positions
  lowerCAmelCase    				= max_target_positions
  lowerCAmelCase    				= num_conv_layers
  lowerCAmelCase    				= list(__lowerCAmelCase     )
  lowerCAmelCase    				= conv_channels
  lowerCAmelCase    				= input_feat_per_channel
  lowerCAmelCase    				= input_channels

  if len(self.conv_kernel_sizes     ) != self.num_conv_layers:
   raise ValueError(
       'Configuration for convolutional module is incorrect. '
       'It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` '
       F'but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes     )}`, '
       F'`config.num_conv_layers = {self.num_conv_layers}`.'     )

  super().__init__(
      pad_token_id=__lowerCAmelCase				,       bos_token_id=__lowerCAmelCase				,       eos_token_id=__lowerCAmelCase				,       is_encoder_decoder=__lowerCAmelCase				,       decoder_start_token_id=__lowerCAmelCase				,       **__lowerCAmelCase				,       )












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




