





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							     =MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING



      def 	lowerCAmelCase__    (	self:						Optional[int]		,  _lowerCAmelCase:						Tuple		,  _lowerCAmelCase:						Optional[int]		,  _lowerCAmelCase:						Dict       )						->    List[str]:
         '''simple docstring'''

         UpperCAmelCase_											=hf_hub_download(
             repo_id="nateraw/video-demo"		,  filename="archery.mp4"		,  repo_type="dataset"       )
         UpperCAmelCase_											=VideoClassificationPipeline(model=__a		,  image_processor=__a		,  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:						Any		,  _lowerCAmelCase:						List[str]		,  _lowerCAmelCase:						List[Any]       )						->    int:
         '''simple docstring'''

         for example in examples:
            UpperCAmelCase_											=video_classifier(__a       )

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



      @require_torch
      def 	lowerCAmelCase__    (	self:						List[Any]       )						->    Optional[Any]:
         '''simple docstring'''

         UpperCAmelCase_											="hf-internal-testing/tiny-random-VideoMAEForVideoClassification"
         UpperCAmelCase_											=VideoMAEFeatureExtractor(
             size={"shortest_edge": 10}		,  crop_size={"height": 10, "width": 10}       )
         UpperCAmelCase_											=pipeline(
             "video-classification"		,  model=__a		,  feature_extractor=__a		,  frame_sampling_rate=4       )

         UpperCAmelCase_											=hf_hub_download(repo_id="nateraw/video-demo"		,  filename="archery.mp4"		,  repo_type="dataset"       )
         UpperCAmelCase_											=video_classifier(__a		,  top_k=2       )
         self.assertEqual(
             nested_simplify(__a		,  decimals=4       )		,  [{"score": 0.51_99, "label": "LABEL_0"}, {"score": 0.48_01, "label": "LABEL_1"}]		,  )

         UpperCAmelCase_											=video_classifier(
             [
                 video_file_path,
                 video_file_path,
             ]		,  top_k=2		,  )
         self.assertEqual(
             nested_simplify(__a		,  decimals=4       )		,  [
                 [{"score": 0.51_99, "label": "LABEL_0"}, {"score": 0.48_01, "label": "LABEL_1"}],
                 [{"score": 0.51_99, "label": "LABEL_0"}, {"score": 0.48_01, "label": "LABEL_1"}],
             ]		,  )






      @require_tf
      def 	lowerCAmelCase__    (	self:						Dict       )						->    int:
         '''simple docstring'''

         pass











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


__lowercase  :   Union[str, Any]						      =logging.get_logger(__name__)

__lowercase  :   List[Any]						      ={
    """tanreinama/GPTSAN-2.8B-spout_is_uniform""": (
        """https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json"""
    ),
}

class      A       (	__lowercase						):
      _snake_case							     ='''gptsan-japanese'''
      _snake_case							     =[
          '''past_key_values''',
      ]
      _snake_case							     ={
          '''hidden_size''': '''d_model''',
          '''num_attention_heads''': '''num_heads''',
          '''num_hidden_layers''': '''num_layers''',
      }



      def __init__(	self:						Optional[Any]		,  _lowerCAmelCase:						List[Any]=3_6000		,  _lowerCAmelCase:						List[Any]=1280		,  _lowerCAmelCase:						str=1024		,  _lowerCAmelCase:						Any=8192		,  _lowerCAmelCase:						str=4096		,  _lowerCAmelCase:						int=128		,  _lowerCAmelCase:						int=10		,  _lowerCAmelCase:						Dict=0		,  _lowerCAmelCase:						Any=16		,  _lowerCAmelCase:						Optional[int]=16		,  _lowerCAmelCase:						List[Any]=128		,  _lowerCAmelCase:						Tuple=0.0		,  _lowerCAmelCase:						Optional[Any]=1e-5		,  _lowerCAmelCase:						int=False		,  _lowerCAmelCase:						Optional[Any]=0.0		,  _lowerCAmelCase:						str="float32"		,  _lowerCAmelCase:						Dict=False		,  _lowerCAmelCase:						Any=False		,  _lowerCAmelCase:						int=False		,  _lowerCAmelCase:						Union[str, Any]=0.0_02		,  _lowerCAmelCase:						Optional[int]=False		,  _lowerCAmelCase:						int=True		,  _lowerCAmelCase:						List[str]=3_5998		,  _lowerCAmelCase:						Optional[int]=3_5995		,  _lowerCAmelCase:						Dict=3_5999		,  **_lowerCAmelCase:						Optional[Any]		,  )						->    List[Any]:
         '''simple docstring'''

         UpperCAmelCase_											=vocab_size
         UpperCAmelCase_											=max_position_embeddings
         UpperCAmelCase_											=d_model
         UpperCAmelCase_											=d_ff
         UpperCAmelCase_											=d_ext
         UpperCAmelCase_											=d_spout
         UpperCAmelCase_											=num_switch_layers
         UpperCAmelCase_											=num_ext_layers
         UpperCAmelCase_											=num_switch_layers + num_ext_layers
         UpperCAmelCase_											=num_heads
         UpperCAmelCase_											=num_experts
         UpperCAmelCase_											=expert_capacity
         UpperCAmelCase_											=dropout_rate
         UpperCAmelCase_											=layer_norm_epsilon
         UpperCAmelCase_											=router_bias
         UpperCAmelCase_											=router_jitter_noise
         UpperCAmelCase_											=router_dtype
         UpperCAmelCase_											=router_ignore_padding_tokens
         UpperCAmelCase_											=output_hidden_states
         UpperCAmelCase_											=output_attentions
         UpperCAmelCase_											=initializer_factor
         UpperCAmelCase_											=output_router_logits
         UpperCAmelCase_											=use_cache

         super().__init__(
             separator_token_id=_lowerCAmelCase		,  pad_token_id=_lowerCAmelCase		,  eos_token_id=_lowerCAmelCase		,  **_lowerCAmelCase		,  )




