






"""simple docstring"""







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


_UpperCamelCase	     =    logging.get_logger(__name__)

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







class    lowerCamelCase__   (			_A					):
    SCREAMING_SNAKE_CASE						=     """nllb-moe"""
    SCREAMING_SNAKE_CASE						=     ["""past_key_values"""]
    SCREAMING_SNAKE_CASE						=     {"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}






    def __init__(					self      ,A=128_112      ,A=1_024      ,A=12      ,A=4_096      ,A=16      ,A=12      ,A=4_096      ,A=16      ,A=0.05      ,A=0.05      ,A=True      ,A=True      ,A="relu"      ,A=1_024      ,A=0.1      ,A=0.1      ,A=0.0      ,A=0.02      ,A=2      ,A=True      ,A=False      ,A="float32"      ,A=False      ,A=128      ,A=64      ,A=4      ,A=4      ,A=0.001      ,A=0.001      ,A="all"      ,A=False      ,A=False      ,A=1.0      ,A=0.2      ,A=1      ,A=0      ,A=2      ,A=False      ,**A      ,):
          UpperCAmelCase							     =			vocab_size
          UpperCAmelCase							     =			max_position_embeddings
          UpperCAmelCase							     =			d_model
          UpperCAmelCase							     =			encoder_ffn_dim
          UpperCAmelCase							     =			encoder_layers
          UpperCAmelCase							     =			encoder_attention_heads
          UpperCAmelCase							     =			decoder_ffn_dim
          UpperCAmelCase							     =			decoder_layers
          UpperCAmelCase							     =			decoder_attention_heads
          UpperCAmelCase							     =			dropout
          UpperCAmelCase							     =			attention_dropout
          UpperCAmelCase							     =			activation_dropout
          UpperCAmelCase							     =			activation_function
          UpperCAmelCase							     =			init_std
          UpperCAmelCase							     =			encoder_layerdrop
          UpperCAmelCase							     =			decoder_layerdrop
          UpperCAmelCase							     =			use_cache
          UpperCAmelCase							     =			encoder_layers
          UpperCAmelCase							     =			scale_embedding  # scale factor will be sqrt(d_model) if True
          UpperCAmelCase							     =			router_z_loss_coef
          UpperCAmelCase							     =			router_aux_loss_coef
          UpperCAmelCase							     =			decoder_sparse_step
          UpperCAmelCase							     =			encoder_sparse_step
          UpperCAmelCase							     =			num_experts
          UpperCAmelCase							     =			expert_capacity
          UpperCAmelCase							     =			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}'''   )
          UpperCAmelCase							     =			router_dtype

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





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin

class 							_UpperCamelCase					(       unittest.TestCase  ,							_A	):






			'''simple docstring'''

			def    lowerCAmelCase__						(							self			:							Tuple   ):
							UpperCamelCase_:				List[Any]						=    load_tool("""text-classification"""   )
							self.tool.setup()
							UpperCamelCase_:				Optional[int]						=    load_tool("""text-classification"""    ,						remote=snake_case_   )

			def    lowerCAmelCase__						(							self			:							Optional[Any]   ):
							UpperCamelCase_:				Union[str, Any]						=    self.tool("""That's quite cool"""    ,						["""positive""", """negative"""]   )
							self.assertEqual(snake_case_    ,						"""positive"""   )

			def    lowerCAmelCase__						(							self			:							int   ):
							UpperCamelCase_:				Tuple						=    self.remote_tool("""That's quite cool"""    ,						["""positive""", """negative"""]   )
							self.assertEqual(snake_case_    ,						"""positive"""   )

			def    lowerCAmelCase__						(							self			:							Optional[int]   ):
							UpperCamelCase_:				int						=    self.tool(text="""That's quite cool"""    ,						labels=["""positive""", """negative"""]   )
							self.assertEqual(snake_case_    ,						"""positive"""   )




			def    lowerCAmelCase__						(							self			:							Tuple   ):
							UpperCamelCase_:				List[Any]						=    self.remote_tool(text="""That's quite cool"""    ,						labels=["""positive""", """negative"""]   )
							self.assertEqual(snake_case_    ,						"""positive"""   )






