



"""simple docstring"""




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


_UpperCamelCase: int										=     logging.get_logger(__name__)

_UpperCamelCase: Dict										=     {
    'abeja/gpt-neox-japanese-2.7b': 'https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json',
}


class      a__						(  UpperCamelCase__   ):
   _lowerCamelCase    							= 'gpt_neox_japanese'


   def __init__(							self					:							str,   lowerCAmelCase					:							List[Any]=32000,   lowerCAmelCase					:							List[Any]=2560,   lowerCAmelCase					:							str=32,   lowerCAmelCase					:							List[Any]=32,   lowerCAmelCase					:							List[str]=4,   lowerCAmelCase					:							Dict="gelu",   lowerCAmelCase					:							Dict=1.00,   lowerCAmelCase					:							Optional[int]=10000,   lowerCAmelCase					:							Dict=2048,   lowerCAmelCase					:							List[str]=0.02,   lowerCAmelCase					:							List[str]=1e-5,   lowerCAmelCase					:							List[str]=True,   lowerCAmelCase					:							List[str]=31996,   lowerCAmelCase					:							Tuple=31999,   lowerCAmelCase					:							List[Any]=0.1,   lowerCAmelCase					:							int=0.0,   **lowerCAmelCase					:							str,   )			->				Union[str, Any]:
         super().__init__(bos_token_id=__lowerCamelCase,   eos_token_id=__lowerCamelCase,   **__lowerCamelCase	)
         lowercase     :					Optional[Any] 		=      vocab_size
         lowercase     :					List[str] 		=      max_position_embeddings
         lowercase     :					Dict 		=      hidden_size
         lowercase     :					List[Any] 		=      num_hidden_layers
         lowercase     :					Optional[Any] 		=      num_attention_heads
         lowercase     :					Union[str, Any] 		=      intermediate_multiple_size
         lowercase     :					str 		=      hidden_act
         lowercase     :					Optional[int] 		=      rotary_pct
         lowercase     :					Optional[Any] 		=      rotary_emb_base
         lowercase     :					Optional[int] 		=      initializer_range
         lowercase     :					int 		=      layer_norm_eps
         lowercase     :					Dict 		=      use_cache
         lowercase     :					str 		=      attention_dropout
         lowercase     :					Optional[int] 		=      hidden_dropout







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      ):
 __SCREAMING_SNAKE_CASE							       =	MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING



 def 				UpperCamelCase			(							self,__lowerCamelCase,__lowerCamelCase,__lowerCamelCase ):
        A__											=						hf_hub_download(
            repo_id='''nateraw/video-demo''',filename='''archery.mp4''',repo_type='''dataset''' )
        A__											=						VideoClassificationPipeline(model=__lowerCamelCase,image_processor=__lowerCamelCase,top_k=2 )
        A__											=						[
            example_video_filepath,
            '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
        ]
        return video_classifier, examples



 def 				UpperCamelCase			(							self,__lowerCamelCase,__lowerCamelCase ):
        for example in examples:
               A__											=						video_classifier(__lowerCamelCase )

               self.assertEqual(
                   __lowerCamelCase,[
                       {'''score''': ANY(__lowerCamelCase ), '''label''': ANY(__lowerCamelCase )},
                       {'''score''': ANY(__lowerCamelCase ), '''label''': ANY(__lowerCamelCase )},
                   ],)



 @require_torch
 def 				UpperCamelCase			(							self ):
        A__											=						'''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
        A__											=						VideoMAEFeatureExtractor(
            size={'''shortest_edge''': 10},crop_size={'''height''': 10, '''width''': 10} )
        A__											=						pipeline(
            '''video-classification''',model=__lowerCamelCase,feature_extractor=__lowerCamelCase,frame_sampling_rate=4 )

        A__											=						hf_hub_download(repo_id='''nateraw/video-demo''',filename='''archery.mp4''',repo_type='''dataset''' )
        A__											=						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'''}],)

        A__											=						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 				UpperCamelCase			(							self ):
        pass





