



'''simple docstring'''

from typing import Any


class 	a__     :


	def __init__(self : List[Any],					__UpperCAmelCase : Any      )     ->			Any:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						Any      					= data
					SCREAMING_SNAKE_CASE  :						Any      					= None






	def __repr__(self : str      )     ->			str:

					"""simple docstring"""

					return F'''Node({self.data})'''



class 	a__     :


	def __init__(self : List[str]      )     ->			Union[str, Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						List[str]      					= None


	def __iter__(self : int      )     ->			Any:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						List[str]      					= self.head
					while node:
									yield node.data
									SCREAMING_SNAKE_CASE  :						Tuple      					= node.next


	def __len__(self : str      )     ->			int:

					"""simple docstring"""

					return sum(1 for _ in self      )


	def __repr__(self : Optional[Any]      )     ->			str:

					"""simple docstring"""

					return "->".join([str(__UpperCAmelCase      ) for item in self]      )


	def __getitem__(self : Any,					__UpperCAmelCase : int      )     ->			Any:

					"""simple docstring"""

					if not 0 <= index < len(self      ):
									raise ValueError('''list index out of range.'''      )
					for i, node in enumerate(self      ):
									if i == index:
													return node
					return None


	def __setitem__(self : Optional[int],					__UpperCAmelCase : int,					__UpperCAmelCase : Any      )     ->			None:

					"""simple docstring"""

					if not 0 <= index < len(self      ):
									raise ValueError('''list index out of range.'''      )
					SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= self.head
					for _ in range(__UpperCAmelCase      ):
									SCREAMING_SNAKE_CASE  :						str      					= current.next
					SCREAMING_SNAKE_CASE  :						str      					= data


	def 				lowercase__  (self : int,					__UpperCAmelCase : Any      )     ->			None:

					"""simple docstring"""

					self.insert_nth(len(self      ),					__UpperCAmelCase      )


	def 				lowercase__  (self : Any,					__UpperCAmelCase : Any      )     ->			None:

					"""simple docstring"""

					self.insert_nth(0,					__UpperCAmelCase      )


	def 				lowercase__  (self : Optional[Any],					__UpperCAmelCase : int,					__UpperCAmelCase : Any      )     ->			None:

					"""simple docstring"""

					if not 0 <= index <= len(self      ):
									raise IndexError('''list index out of range'''      )
					SCREAMING_SNAKE_CASE  :						Tuple      					= Node(__UpperCAmelCase      )
					if self.head is None:
									SCREAMING_SNAKE_CASE  :						Optional[Any]      					= new_node
					elif index == 0:
									SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= self.head  # link new_node to head
									SCREAMING_SNAKE_CASE  :						List[str]      					= new_node
					else:
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= self.head
									for _ in range(index - 1      ):
													SCREAMING_SNAKE_CASE  :						Any      					= temp.next
									SCREAMING_SNAKE_CASE  :						Any      					= temp.next
									SCREAMING_SNAKE_CASE  :						List[Any]      					= new_node


	def 				lowercase__  (self : Any      )     ->			None:  # print every node data

					"""simple docstring"""

					print(self      )


	def 				lowercase__  (self : List[Any]      )     ->			Any:

					"""simple docstring"""

					return self.delete_nth(0      )


	def 				lowercase__  (self : Optional[Any]      )     ->			Any:  # delete from tail

					"""simple docstring"""

					return self.delete_nth(len(self      ) - 1      )


	def 				lowercase__  (self : Optional[int],					__UpperCAmelCase : int = 0      )     ->			Any:

					"""simple docstring"""

					if not 0 <= index <= len(self      ) - 1:  # test if index is valid
									raise IndexError('''List index out of range.'''      )
					SCREAMING_SNAKE_CASE  :						str      					= self.head  # default first node
					if index == 0:
									SCREAMING_SNAKE_CASE  :						List[Any]      					= self.head.next
					else:
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= self.head
									for _ in range(index - 1      ):
													SCREAMING_SNAKE_CASE  :						List[str]      					= temp.next
									SCREAMING_SNAKE_CASE  :						Dict      					= temp.next
									SCREAMING_SNAKE_CASE  :						Dict      					= temp.next.next
					return delete_node.data


	def 				lowercase__  (self : Any      )     ->			bool:

					"""simple docstring"""

					return self.head is None






	def 				lowercase__  (self : List[str]      )     ->			None:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						int      					= None
					SCREAMING_SNAKE_CASE  :						Optional[int]      					= self.head

					while current:
									# Store the current node's next node.
									SCREAMING_SNAKE_CASE  :						int      					= current.next
									# Make the current node's next point backwards
									SCREAMING_SNAKE_CASE  :						int      					= prev
									# Make the previous node be the current node
									SCREAMING_SNAKE_CASE  :						str      					= current
									# Make the current node the next node (to progress iteration)
									SCREAMING_SNAKE_CASE  :						Optional[Any]      					= next_node
					# Return prev in order to put the head at the end
					SCREAMING_SNAKE_CASE  :						str      					= prev






def       __lowercase  ():
				SCREAMING_SNAKE_CASE  :						int      					= LinkedList()
				assert linked_list.is_empty() is True
				assert str(_SCREAMING_SNAKE_CASE       ) == ""

				try:
								linked_list.delete_head()
								raise AssertionError  # This should not happen.
				except IndexError:
								assert True  # This should happen.

				try:
								linked_list.delete_tail()
								raise AssertionError  # This should not happen.
				except IndexError:
								assert True  # This should happen.

				for i in range(10       ):
								assert len(_SCREAMING_SNAKE_CASE       ) == i
								linked_list.insert_nth(_SCREAMING_SNAKE_CASE    ,	i + 1       )
				assert str(_SCREAMING_SNAKE_CASE       ) == "->".join(str(_SCREAMING_SNAKE_CASE       ) for i in range(1    ,	11       )       )

				linked_list.insert_head(0       )
				linked_list.insert_tail(11       )
				assert str(_SCREAMING_SNAKE_CASE       ) == "->".join(str(_SCREAMING_SNAKE_CASE       ) for i in range(0    ,	12       )       )

				assert linked_list.delete_head() == 0
				assert linked_list.delete_nth(9       ) == 10
				assert linked_list.delete_tail() == 11
				assert len(_SCREAMING_SNAKE_CASE       ) == 9
				assert str(_SCREAMING_SNAKE_CASE       ) == "->".join(str(_SCREAMING_SNAKE_CASE       ) for i in range(1    ,	10       )       )

				assert all(linked_list[i] == i + 1 for i in range(0    ,	9       )       ) is True

				for i in range(0    ,	9       ):
								SCREAMING_SNAKE_CASE  :						List[str]      					= -i
				assert all(linked_list[i] == -i for i in range(0    ,	9       )       ) is True

				linked_list.reverse()
				assert str(_SCREAMING_SNAKE_CASE       ) == "->".join(str(_SCREAMING_SNAKE_CASE       ) for i in range(-8    ,	1       )       )






def       __lowercase  ():
				SCREAMING_SNAKE_CASE  :						str      					= [
				    -9,
				    1_00,
				    Node(77_34_51_12       ),
				    '''dlrow olleH''',
				    7,
				    55_55,
				    0,
				    -192.5_5555,
				    '''Hello, world!''',
				    77.9,
				    Node(10       ),
				    None,
				    None,
				    12.20,
				]
				SCREAMING_SNAKE_CASE  :						int      					= LinkedList()

				for i in test_input:
								linked_list.insert_tail(_SCREAMING_SNAKE_CASE       )

				# Check if it's empty or not
				assert linked_list.is_empty() is False
				assert (
				    str(_SCREAMING_SNAKE_CASE       ) == "-9->100->Node(77345112)->dlrow olleH->7->5555->0->"
				    "-192.55555->Hello, world!->77.9->Node(10)->None->None->12.2"
				)

				# Delete the head
				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= linked_list.delete_head()
				assert result == -9
				assert (
				    str(_SCREAMING_SNAKE_CASE       ) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
				    "Hello, world!->77.9->Node(10)->None->None->12.2"
				)

				# Delete the tail
				SCREAMING_SNAKE_CASE  :						int      					= linked_list.delete_tail()
				assert result == 12.2
				assert (
				    str(_SCREAMING_SNAKE_CASE       ) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
				    "Hello, world!->77.9->Node(10)->None->None"
				)

				# Delete a node in specific location in linked list
				SCREAMING_SNAKE_CASE  :						Optional[int]      					= linked_list.delete_nth(10       )
				assert result is None
				assert (
				    str(_SCREAMING_SNAKE_CASE       ) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
				    "Hello, world!->77.9->Node(10)->None"
				)

				# Add a Node instance to its head
				linked_list.insert_head(Node('''Hello again, world!'''       )       )
				assert (
				    str(_SCREAMING_SNAKE_CASE       )
				    == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
				    "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None"
				)

				# Add None to its tail
				linked_list.insert_tail(_SCREAMING_SNAKE_CASE       )
				assert (
				    str(_SCREAMING_SNAKE_CASE       )
				    == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
				    "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None->None"
				)

				# Reverse the linked list
				linked_list.reverse()
				assert (
				    str(_SCREAMING_SNAKE_CASE       )
				    == "None->None->Node(10)->77.9->Hello, world!->-192.55555->0->5555->"
				    "7->dlrow olleH->Node(77345112)->100->Node(Hello again, world!)"
				)






def       __lowercase  ():
				from doctest import testmod

				testmod()

				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= LinkedList()
				linked_list.insert_head(input('''Inserting 1st at head '''       ).strip()       )
				linked_list.insert_head(input('''Inserting 2nd at head '''       ).strip()       )
				print('''\nPrint list:'''       )
				linked_list.print_list()
				linked_list.insert_tail(input('''\nInserting 1st at tail '''       ).strip()       )
				linked_list.insert_tail(input('''Inserting 2nd at tail '''       ).strip()       )
				print('''\nPrint list:'''       )
				linked_list.print_list()
				print('''\nDelete head'''       )
				linked_list.delete_head()
				print('''Delete tail'''       )
				linked_list.delete_tail()
				print('''\nPrint list:'''       )
				linked_list.print_list()
				print('''\nReverse linked list'''       )
				linked_list.reverse()
				print('''\nPrint list:'''       )
				linked_list.print_list()
				print('''\nString representation of linked list:'''       )
				print(_SCREAMING_SNAKE_CASE       )
				print('''\nReading/changing Node data using indexing:'''       )
				print(F'''Element at Position 1: {linked_list[1]}'''       )
				SCREAMING_SNAKE_CASE  :						Optional[int]      					= input('''Enter New Value: '''       ).strip()
				print('''New list:'''       )
				print(_SCREAMING_SNAKE_CASE       )
				print(F'''length of linked_list is : {len(_SCREAMING_SNAKE_CASE       )}'''       )


if __name__ == "__main__":
	main()









'''simple docstring'''

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


snake_case_			=     logging.get_logger(__name__)

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


class 	a__     (				_lowercase	):
	__magic_name__		:    Optional[Any]	    =     "nllb-moe"
	__magic_name__		:    Optional[Any]	    =     ["past_key_values"]
	__magic_name__		:    Optional[int]	    =     {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


	def __init__(self : int,					__UpperCAmelCase : Tuple=128112,					__UpperCAmelCase : Any=1024,					__UpperCAmelCase : Optional[Any]=12,					__UpperCAmelCase : Optional[int]=4096,					__UpperCAmelCase : Any=16,					__UpperCAmelCase : Any=12,					__UpperCAmelCase : Optional[Any]=4096,					__UpperCAmelCase : Optional[int]=16,					__UpperCAmelCase : List[Any]=0.05,					__UpperCAmelCase : Dict=0.05,					__UpperCAmelCase : Dict=True,					__UpperCAmelCase : List[Any]=True,					__UpperCAmelCase : Any="relu",					__UpperCAmelCase : Union[str, Any]=1024,					__UpperCAmelCase : Optional[int]=0.1,					__UpperCAmelCase : Tuple=0.1,					__UpperCAmelCase : List[Any]=0.0,					__UpperCAmelCase : Optional[int]=0.02,					__UpperCAmelCase : Tuple=2,					__UpperCAmelCase : int=True,					__UpperCAmelCase : int=False,					__UpperCAmelCase : int="float32",					__UpperCAmelCase : Optional[Any]=False,					__UpperCAmelCase : List[str]=128,					__UpperCAmelCase : Dict=64,					__UpperCAmelCase : Dict=4,					__UpperCAmelCase : Optional[Any]=4,					__UpperCAmelCase : Optional[Any]=0.001,					__UpperCAmelCase : Optional[Any]=0.001,					__UpperCAmelCase : Optional[Any]="all",					__UpperCAmelCase : List[str]=False,					__UpperCAmelCase : Dict=False,					__UpperCAmelCase : Any=1.0,					__UpperCAmelCase : Dict=0.2,					__UpperCAmelCase : int=1,					__UpperCAmelCase : Union[str, Any]=0,					__UpperCAmelCase : Any=2,					__UpperCAmelCase : Union[str, Any]=False,					**__UpperCAmelCase : Dict,					)     ->			List[Any]:

					"""simple docstring"""

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

					SCREAMING_SNAKE_CASE  :						int      					= router_ignore_padding_tokens
					SCREAMING_SNAKE_CASE  :						Dict      					= batch_prioritized_routing
					SCREAMING_SNAKE_CASE  :						Dict      					= second_expert_policy
					SCREAMING_SNAKE_CASE  :						Tuple      					= normalize_router_prob_before_dropping
					SCREAMING_SNAKE_CASE  :						List[str]      					= moe_eval_capacity_token_fraction
					SCREAMING_SNAKE_CASE  :						List[Any]      					= moe_token_dropout
					SCREAMING_SNAKE_CASE  :						List[Any]      					= 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,					)




