'''simple docstring'''

import math
from typing import Optional

import numpy as np

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


_A			:      Optional[Any]					      =				logging.get_logger(__name__)

_A			:      List[Any]					      =				{
    """facebook/encodec_24khz""": """https://huggingface.co/facebook/encodec_24khz/resolve/main/config.json""",
    """facebook/encodec_48khz""": """https://huggingface.co/facebook/encodec_48khz/resolve/main/config.json""",
}







class 				_lowercase     (				UpperCAmelCase__			):


 '''simple docstring'''






 _SCREAMING_SNAKE_CASE     :       int      	=					"encodec"
 def __init__(      self   :	str      ,       SCREAMING_SNAKE_CASE__   :	Optional[Any]=[1.5, 3.0, 6.0, 1_2.0, 2_4.0]      ,       SCREAMING_SNAKE_CASE__   :	List[Any]=2_40_00      ,       SCREAMING_SNAKE_CASE__   :	Dict=1      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]=False      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]=None      ,       SCREAMING_SNAKE_CASE__   :	int=None      ,       SCREAMING_SNAKE_CASE__   :	int=1_28      ,       SCREAMING_SNAKE_CASE__   :	Dict=32      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]=1      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]=[8, 5, 4, 2]      ,       SCREAMING_SNAKE_CASE__   :	int="weight_norm"      ,       SCREAMING_SNAKE_CASE__   :	Optional[int]=7      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]=7      ,       SCREAMING_SNAKE_CASE__   :	Tuple=3      ,       SCREAMING_SNAKE_CASE__   :	str=2      ,       SCREAMING_SNAKE_CASE__   :	Optional[int]=True      ,       SCREAMING_SNAKE_CASE__   :	str="reflect"      ,       SCREAMING_SNAKE_CASE__   :	Optional[int]=2      ,       SCREAMING_SNAKE_CASE__   :	Any=2      ,       SCREAMING_SNAKE_CASE__   :	str=1.0      ,       SCREAMING_SNAKE_CASE__   :	List[Any]=10_24      ,       SCREAMING_SNAKE_CASE__   :	int=None      ,       SCREAMING_SNAKE_CASE__   :	Optional[Any]=True      ,       **SCREAMING_SNAKE_CASE__   :	List[str]      ,       )  ->    str:
  __lowerCAmelCase											=						target_bandwidths
  __lowerCAmelCase											=						sampling_rate
  __lowerCAmelCase											=						audio_channels
  __lowerCAmelCase											=						normalize
  __lowerCAmelCase											=						chunk_length_s
  __lowerCAmelCase											=						overlap
  __lowerCAmelCase											=						hidden_size
  __lowerCAmelCase											=						num_filters
  __lowerCAmelCase											=						num_residual_layers
  __lowerCAmelCase											=						upsampling_ratios
  __lowerCAmelCase											=						norm_type
  __lowerCAmelCase											=						kernel_size
  __lowerCAmelCase											=						last_kernel_size
  __lowerCAmelCase											=						residual_kernel_size
  __lowerCAmelCase											=						dilation_growth_rate
  __lowerCAmelCase											=						use_causal_conv
  __lowerCAmelCase											=						pad_mode
  __lowerCAmelCase											=						compress
  __lowerCAmelCase											=						num_lstm_layers
  __lowerCAmelCase											=						trim_right_ratio
  __lowerCAmelCase											=						codebook_size
  __lowerCAmelCase											=						codebook_dim if codebook_dim is not None else hidden_size
  __lowerCAmelCase											=						use_conv_shortcut

  if self.norm_type not in ["weight_norm", "time_group_norm"]:
   raise ValueError(
       f"""self.norm_type must be one of `\"weight_norm\"`, `\"time_group_norm\"`), got {self.norm_type}"""							)

  super().__init__(**SCREAMING_SNAKE_CASE__							)
 @property
 def a					(      self   :	Optional[Any]							)  ->    Optional[int]:







  if self.chunk_length_s is None:
   return None
  else:
   return int(self.chunk_length_s * self.sampling_rate							)
 @property
 def a					(      self   :	List[str]							)  ->    int:







  if self.chunk_length_s is None or self.overlap is None:
   return None
  else:
   return max(1      ,       int((1.0 - self.overlap) * self.chunk_length							)							)
 @property
 def a					(      self   :	List[str]							)  ->    List[str]:
  __lowerCAmelCase											=						np.prod(self.upsampling_ratios							)
  return math.ceil(self.sampling_rate / hop_length							)





 @property
 def a					(      self   :	List[str]							)  ->    str:
  return int(10_00 * self.target_bandwidths[-1] // (self.frame_rate * 10)							)








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 __snake_case		(      unittest.TestCase     ):
    _a		:						Optional[int]=				MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case		,snake_case		,snake_case      ):



           '''simple docstring'''







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



           '''simple docstring'''







           for example in examples:
                  lowercase							:     int       	=      video_classifier(snake_case      )

                  self.assertEqual(
                      snake_case		,[
                          {"""score""": ANY(snake_case      ), """label""": ANY(snake_case      )},
                          {"""score""": ANY(snake_case      ), """label""": ANY(snake_case      )},
                      ]		,)
    @require_torch
    def       _SCREAMING_SNAKE_CASE       (  self      ):



           '''simple docstring'''







           lowercase							:     Any       	=      """hf-internal-testing/tiny-random-VideoMAEForVideoClassification"""
           lowercase							:     str       	=      VideoMAEFeatureExtractor(
               size={"""shortest_edge""": 10}		,crop_size={"""height""": 10, """width""": 10}      )
           lowercase							:     List[Any]       	=      pipeline(
               """video-classification"""		,model=snake_case		,feature_extractor=snake_case		,frame_sampling_rate=4      )

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

           lowercase							:     str       	=      video_classifier(
               [
                   video_file_path,
                   video_file_path,
               ]		,top_k=2		,)
           self.assertEqual(
               nested_simplify(snake_case		,decimals=4      )		,[
                   [{"""score""": 0.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}],
                   [{"""score""": 0.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}],
               ]		,)
    @require_tf
    def       _SCREAMING_SNAKE_CASE       (  self      ):



           '''simple docstring'''







           pass
