




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


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

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




class 		__A      (			UpperCamelCase__			):
						UpperCamelCase     						=					"""nllb-moe"""
						UpperCamelCase     						=					["""past_key_values"""]
						UpperCamelCase     						=					{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}

						def __init__(		self   :Dict    , __snake_case   :Optional[Any]=12_81_12    , __snake_case   :List[Any]=10_24    , __snake_case   :str=12    , __snake_case   :List[Any]=40_96    , __snake_case   :int=16    , __snake_case   :int=12    , __snake_case   :int=40_96    , __snake_case   :Any=16    , __snake_case   :Dict=0.05    , __snake_case   :int=0.05    , __snake_case   :Union[str, Any]=True    , __snake_case   :List[Any]=True    , __snake_case   :str="relu"    , __snake_case   :Tuple=10_24    , __snake_case   :Union[str, Any]=0.1    , __snake_case   :int=0.1    , __snake_case   :Optional[Any]=0.0    , __snake_case   :str=0.02    , __snake_case   :str=2    , __snake_case   :Optional[int]=True    , __snake_case   :Union[str, Any]=False    , __snake_case   :Any="float32"    , __snake_case   :List[str]=False    , __snake_case   :Optional[Any]=1_28    , __snake_case   :int=64    , __snake_case   :Optional[Any]=4    , __snake_case   :int=4    , __snake_case   :Optional[int]=0.001    , __snake_case   :str=0.001    , __snake_case   :str="all"    , __snake_case   :Dict=False    , __snake_case   :List[str]=False    , __snake_case   :Tuple=1.0    , __snake_case   :int=0.2    , __snake_case   :Tuple=1    , __snake_case   :Union[str, Any]=0    , __snake_case   :Tuple=2    , __snake_case   :int=False    , **__snake_case   :Dict    , ):
										'''simple docstring'''

										__magic_name__	:	Dict								=vocab_size
										__magic_name__	:	Tuple								=max_position_embeddings
										__magic_name__	:	Tuple								=d_model
										__magic_name__	:	List[Any]								=encoder_ffn_dim
										__magic_name__	:	Any								=encoder_layers
										__magic_name__	:	Optional[int]								=encoder_attention_heads
										__magic_name__	:	List[str]								=decoder_ffn_dim
										__magic_name__	:	List[Any]								=decoder_layers
										__magic_name__	:	Tuple								=decoder_attention_heads
										__magic_name__	:	int								=dropout
										__magic_name__	:	int								=attention_dropout
										__magic_name__	:	Optional[Any]								=activation_dropout
										__magic_name__	:	Optional[Any]								=activation_function
										__magic_name__	:	Optional[Any]								=init_std
										__magic_name__	:	List[Any]								=encoder_layerdrop
										__magic_name__	:	str								=decoder_layerdrop
										__magic_name__	:	str								=use_cache
										__magic_name__	:	Dict								=encoder_layers
										__magic_name__	:	Any								=scale_embedding  # scale factor will be sqrt(d_model) if True
										__magic_name__	:	Dict								=router_z_loss_coef
										__magic_name__	:	Tuple								=router_aux_loss_coef
										__magic_name__	:	Tuple								=decoder_sparse_step
										__magic_name__	:	List[Any]								=encoder_sparse_step
										__magic_name__	:	str								=num_experts
										__magic_name__	:	List[str]								=expert_capacity
										__magic_name__	:	Dict								=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}" )
										__magic_name__	:	List[Any]								=router_dtype

										__magic_name__	:	str								=router_ignore_padding_tokens
										__magic_name__	:	str								=batch_prioritized_routing
										__magic_name__	:	Any								=second_expert_policy
										__magic_name__	:	Optional[Any]								=normalize_router_prob_before_dropping
										__magic_name__	:	List[str]								=moe_eval_capacity_token_fraction
										__magic_name__	:	Any								=moe_token_dropout
										__magic_name__	:	Union[str, Any]								=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 pytest

import datasets


# Import fixture modules as plugins
UpperCAmelCase_		:				Union[str, Any]									=     ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase   ):
				# Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit")
				for item in items:
								if any(marker in item.keywords for marker in ["""integration""", """unit"""]   ):
												continue
								item.add_marker(pytest.mark.unit   )




def 		lowerCAmelCase_   (	lowerCamelCase   ):
				config.addinivalue_line("""markers"""	,     """torchaudio_latest: mark test to run with torchaudio>=0.12"""   )




@pytest.fixture(autouse=lowerCamelCase   )
def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase   ):
				# test_hf_cache_home = tmp_path_factory.mktemp("cache")  # TODO: why a cache dir per test function does not work?
				__magic_name__	:	Tuple								=tmp_path_factory.getbasetemp() / """cache"""
				__magic_name__	:	Optional[int]								=test_hf_cache_home / """datasets"""
				__magic_name__	:	List[str]								=test_hf_cache_home / """metrics"""
				__magic_name__	:	List[str]								=test_hf_cache_home / """modules"""
				monkeypatch.setattr("""datasets.config.HF_DATASETS_CACHE"""	,     str(lowerCamelCase   )   )
				monkeypatch.setattr("""datasets.config.HF_METRICS_CACHE"""	,     str(lowerCamelCase   )   )
				monkeypatch.setattr("""datasets.config.HF_MODULES_CACHE"""	,     str(lowerCamelCase   )   )
				__magic_name__	:	Optional[Any]								=test_hf_datasets_cache / """downloads"""
				monkeypatch.setattr("""datasets.config.DOWNLOADED_DATASETS_PATH"""	,     str(lowerCamelCase   )   )
				__magic_name__	:	Tuple								=test_hf_datasets_cache / """downloads""" / """extracted"""
				monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""	,     str(lowerCamelCase   )   )




@pytest.fixture(autouse=lowerCamelCase	,     scope="""session"""   )
def 		lowerCAmelCase_   (	):
				datasets.disable_progress_bar()




@pytest.fixture(autouse=lowerCamelCase   )
def 		lowerCAmelCase_   (	lowerCamelCase   ):
				# don't take tests into account when counting downloads
				monkeypatch.setattr("""datasets.config.HF_UPDATE_DOWNLOAD_COUNTS"""	,     lowerCamelCase   )




@pytest.fixture
def 		lowerCAmelCase_   (	lowerCamelCase   ):
				# Required to suppress RemovedIn20Warning when feature(s) are not compatible with SQLAlchemy 2.0
				# To be removed once SQLAlchemy 2.0 supported
				monkeypatch.setattr("""sqlalchemy.util.deprecations.SILENCE_UBER_WARNING"""	,     lowerCamelCase   )




