'''simple docstring'''






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


_UpperCAmelCase    :     Dict         =       logging.get_logger(__name__)

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







class lowercase_       (		_UpperCamelCase			):







   """simple docstring"""

   __lowerCAmelCase         =   "nllb-moe"
   __lowerCAmelCase         =   ["past_key_values"]
   __lowerCAmelCase         =   {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}
   def __init__(      self      :			List[Any], UpperCamelCase__      :			str=12_81_12, UpperCamelCase__      :			str=10_24, UpperCamelCase__      :			Optional[int]=12, UpperCamelCase__      :			Any=40_96, UpperCamelCase__      :			Union[str, Any]=16, UpperCamelCase__      :			Dict=12, UpperCamelCase__      :			Union[str, Any]=40_96, UpperCamelCase__      :			Any=16, UpperCamelCase__      :			Tuple=0.05, UpperCamelCase__      :			Dict=0.05, UpperCamelCase__      :			List[Any]=True, UpperCamelCase__      :			Union[str, Any]=True, UpperCamelCase__      :			List[Any]="relu", UpperCamelCase__      :			int=10_24, UpperCamelCase__      :			Any=0.1, UpperCamelCase__      :			Optional[Any]=0.1, UpperCamelCase__      :			Dict=0.0, UpperCamelCase__      :			List[Any]=0.02, UpperCamelCase__      :			str=2, UpperCamelCase__      :			Optional[int]=True, UpperCamelCase__      :			Optional[int]=False, UpperCamelCase__      :			int="float32", UpperCamelCase__      :			Optional[Any]=False, UpperCamelCase__      :			Dict=1_28, UpperCamelCase__      :			Optional[int]=64, UpperCamelCase__      :			Tuple=4, UpperCamelCase__      :			Any=4, UpperCamelCase__      :			Dict=0.001, UpperCamelCase__      :			List[str]=0.001, UpperCamelCase__      :			Union[str, Any]="all", UpperCamelCase__      :			Tuple=False, UpperCamelCase__      :			Dict=False, UpperCamelCase__      :			Any=1.0, UpperCamelCase__      :			Tuple=0.2, UpperCamelCase__      :			Optional[int]=1, UpperCamelCase__      :			int=0, UpperCamelCase__      :			List[str]=2, UpperCamelCase__      :			str=False, **UpperCamelCase__      :			Union[str, Any], )  ->			Tuple:
        _A    		=  vocab_size
        _A    		=  max_position_embeddings
        _A    		=  d_model
        _A    		=  encoder_ffn_dim
        _A    		=  encoder_layers
        _A    		=  encoder_attention_heads
        _A    		=  decoder_ffn_dim
        _A    		=  decoder_layers
        _A    		=  decoder_attention_heads
        _A    		=  dropout
        _A    		=  attention_dropout
        _A    		=  activation_dropout
        _A    		=  activation_function
        _A    		=  init_std
        _A    		=  encoder_layerdrop
        _A    		=  decoder_layerdrop
        _A    		=  use_cache
        _A    		=  encoder_layers
        _A    		=  scale_embedding  # scale factor will be sqrt(d_model) if True
        _A    		=  router_z_loss_coef
        _A    		=  router_aux_loss_coef
        _A    		=  decoder_sparse_step
        _A    		=  encoder_sparse_step
        _A    		=  num_experts
        _A    		=  expert_capacity
        _A    		=  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}'     )
        _A    		=  router_dtype

        _A    		=  router_ignore_padding_tokens
        _A    		=  batch_prioritized_routing
        _A    		=  second_expert_policy
        _A    		=  normalize_router_prob_before_dropping
        _A    		=  moe_eval_capacity_token_fraction
        _A    		=  moe_token_dropout
        _A    		=  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'''

# Author: OMKAR PATHAK, Nwachukwu Chidiebere

# Use a Python dictionary to construct the graph.
from __future__ import annotations

from pprint import pformat
from typing import Generic, TypeVar

__lowerCAmelCase		     =  TypeVar('''T''')

class       __magic_name__		(       Generic[T]  ):







							def __init__(				self   :			int      ,_UpperCAmelCase   :			bool = True						):
									_a	: dict[T, list[T]]								=				{}  # dictionary of lists
									_a	: Tuple								=				directed







							def 				__lowercase     (				self   :			Union[str, Any]      ,_UpperCAmelCase   :			T      ,_UpperCAmelCase   :			T						):

									if not self.directed:  # For undirected graphs
											# if both source vertex and destination vertex are both present in the
											# adjacency list, add destination vertex to source vertex list of adjacent
											# vertices and add source vertex to destination vertex list of adjacent
											# vertices.
											if source_vertex in self.adj_list and destination_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
													self.adj_list[destination_vertex].append(_UpperCAmelCase						)
											# if only source vertex is present in adjacency list, add destination vertex
											# to source vertex list of adjacent vertices, then create a new vertex with
											# destination vertex as key and assign a list containing the source vertex
											# as it's first adjacent vertex.
											elif source_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
													_a	: Optional[Any]								=				[source_vertex]
											# if only destination vertex is present in adjacency list, add source vertex
											# to destination vertex list of adjacent vertices, then create a new vertex
											# with source vertex as key and assign a list containing the source vertex
											# as it's first adjacent vertex.
											elif destination_vertex in self.adj_list:
													self.adj_list[destination_vertex].append(_UpperCAmelCase						)
													_a	: Union[str, Any]								=				[destination_vertex]
											# if both source vertex and destination vertex are not present in adjacency
											# list, create a new vertex with source vertex as key and assign a list
											# containing the destination vertex as it's first adjacent vertex also
											# create a new vertex with destination vertex as key and assign a list
											# containing the source vertex as it's first adjacent vertex.
											else:
													_a	: Union[str, Any]								=				[destination_vertex]
													_a	: Optional[int]								=				[source_vertex]
									else:  # For directed graphs
											# if both source vertex and destination vertex are present in adjacency
											# list, add destination vertex to source vertex list of adjacent vertices.
											if source_vertex in self.adj_list and destination_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
											# if only source vertex is present in adjacency list, add destination
											# vertex to source vertex list of adjacent vertices and create a new vertex
											# with destination vertex as key, which has no adjacent vertex
											elif source_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
													_a	: int								=				[]
											# if only destination vertex is present in adjacency list, create a new
											# vertex with source vertex as key and assign a list containing destination
											# vertex as first adjacent vertex
											elif destination_vertex in self.adj_list:
													_a	: Tuple								=				[destination_vertex]
											# if both source vertex and destination vertex are not present in adjacency
											# list, create a new vertex with source vertex as key and a list containing
											# destination vertex as it's first adjacent vertex. Then create a new vertex
											# with destination vertex as key, which has no adjacent vertex
											else:
													_a	: Tuple								=				[destination_vertex]
													_a	: str								=				[]

									return self







							def __repr__(				self   :			int						):
									return pformat(self.adj_list						)




