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


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

lowerCAmelCase_:					Any     =					{
    "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json",
}






class    a__    (   _a	):
   snake_case_							=      "nllb-moe"
   snake_case_							=      ["past_key_values"]
   snake_case_							=      {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


   def __init__(     self,				_UpperCAmelCase=12_8112,				_UpperCAmelCase=1024,				_UpperCAmelCase=12,				_UpperCAmelCase=4096,				_UpperCAmelCase=16,				_UpperCAmelCase=12,				_UpperCAmelCase=4096,				_UpperCAmelCase=16,				_UpperCAmelCase=0.05,				_UpperCAmelCase=0.05,				_UpperCAmelCase=True,				_UpperCAmelCase=True,				_UpperCAmelCase="relu",				_UpperCAmelCase=1024,				_UpperCAmelCase=0.1,				_UpperCAmelCase=0.1,				_UpperCAmelCase=0.0,				_UpperCAmelCase=0.02,				_UpperCAmelCase=2,				_UpperCAmelCase=True,				_UpperCAmelCase=False,				_UpperCAmelCase="float32",				_UpperCAmelCase=False,				_UpperCAmelCase=128,				_UpperCAmelCase=64,				_UpperCAmelCase=4,				_UpperCAmelCase=4,				_UpperCAmelCase=0.001,				_UpperCAmelCase=0.001,				_UpperCAmelCase="all",				_UpperCAmelCase=False,				_UpperCAmelCase=False,				_UpperCAmelCase=1.0,				_UpperCAmelCase=0.2,				_UpperCAmelCase=1,				_UpperCAmelCase=0,				_UpperCAmelCase=2,				_UpperCAmelCase=False,				**_UpperCAmelCase,				):
        '''simple docstring'''



        lowercase__				 =							vocab_size
        lowercase__				 =							max_position_embeddings
        lowercase__				 =							d_model
        lowercase__				 =							encoder_ffn_dim
        lowercase__				 =							encoder_layers
        lowercase__				 =							encoder_attention_heads
        lowercase__				 =							decoder_ffn_dim
        lowercase__				 =							decoder_layers
        lowercase__				 =							decoder_attention_heads
        lowercase__				 =							dropout
        lowercase__				 =							attention_dropout
        lowercase__				 =							activation_dropout
        lowercase__				 =							activation_function
        lowercase__				 =							init_std
        lowercase__				 =							encoder_layerdrop
        lowercase__				 =							decoder_layerdrop
        lowercase__				 =							use_cache
        lowercase__				 =							encoder_layers
        lowercase__				 =							scale_embedding  # scale factor will be sqrt(d_model) if True
        lowercase__				 =							router_z_loss_coef
        lowercase__				 =							router_aux_loss_coef
        lowercase__				 =							decoder_sparse_step
        lowercase__				 =							encoder_sparse_step
        lowercase__				 =							num_experts
        lowercase__				 =							expert_capacity
        lowercase__				 =							router_bias
        if router_dtype not in ["float32", "float16", "bfloat16"]:
             raise ValueError(F'''`router_dtype` must be one of \'float32\', \'float16\' or \'bfloat16\', got {router_dtype}'''  )
        lowercase__				 =							router_dtype

        lowercase__				 =							router_ignore_padding_tokens
        lowercase__				 =							batch_prioritized_routing
        lowercase__				 =							second_expert_policy
        lowercase__				 =							normalize_router_prob_before_dropping
        lowercase__				 =							moe_eval_capacity_token_fraction
        lowercase__				 =							moe_token_dropout
        lowercase__				 =							output_router_logits
        super().__init__(
            pad_token_id=_UpperCAmelCase,				bos_token_id=_UpperCAmelCase,				eos_token_id=_UpperCAmelCase,				is_encoder_decoder=_UpperCAmelCase,				decoder_start_token_id=_UpperCAmelCase,				**_UpperCAmelCase,				)





"""simple docstring"""


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 	snake_case__	(     self,				_UpperCAmelCase,				_UpperCAmelCase,				_UpperCAmelCase  ):
        '''simple docstring'''



        lowercase__				 =							hf_hub_download(
            repo_id="nateraw/video-demo",				filename="archery.mp4",				repo_type="dataset"  )
        lowercase__				 =							VideoClassificationPipeline(model=_UpperCAmelCase,				image_processor=_UpperCAmelCase,				top_k=2  )
        lowercase__				 =							[
            example_video_filepath,
            "https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4",
        ]
        return video_classifier, examples


   def 	snake_case__	(     self,				_UpperCAmelCase,				_UpperCAmelCase  ):
        '''simple docstring'''



        for example in examples:
             lowercase__				 =							video_classifier(_UpperCAmelCase  )

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


   @require_torch
   def 	snake_case__	(     self  ):
        '''simple docstring'''



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

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

        lowercase__				 =							video_classifier(
            [
                video_file_path,
                video_file_path,
            ],				top_k=2,				)
        self.assertEqual(
            nested_simplify(_UpperCAmelCase,				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 	snake_case__	(     self  ):
        '''simple docstring'''



        pass




