




"""simple docstring"""






from __future__ import annotations

from collections.abc import Iterator
from typing import Any






class lowerCAmelCase__      :






			'''simple docstring'''



			def __init__(    self    , lowercase    ):
							_lowerCamelCase	:     Any       =       data
							_lowerCamelCase	:     Node | None       =       None






class lowerCAmelCase__      :






			'''simple docstring'''



			def __init__(    self    ):
							_lowerCamelCase	:     Dict       =       None
							_lowerCamelCase	:     Optional[int]       =       None
			def __iter__(    self    ):
							_lowerCamelCase	:     str       =       self.head
							while self.head:
											yield node.data
											_lowerCamelCase	:     Any       =       node.next
											if node == self.head:
															break
			def __len__(    self    ):
							return sum(1 for _ in self    )
			def __repr__(    self    ):
							return "->".join(str(lowercase    ) for item in iter(self    )    )
			def    A_       (    self    , lowercase    ):
							self.insert_nth(len(self    )    , lowercase    )
			def    A_       (    self    , lowercase    ):
							self.insert_nth(0    , lowercase    )
			def    A_       (    self    , lowercase    , lowercase    ):
							if index < 0 or index > len(self    ):
											raise IndexError('list index out of range.'    )
							_lowerCamelCase	:     Union[str, Any]       =       Node(lowercase    )
							if self.head is None:
											_lowerCamelCase	:     Dict       =       new_node  # first node points itself
											_lowerCamelCase	:     List[str]       =       new_node
							elif index == 0:  # insert at head
											_lowerCamelCase	:     Dict       =       self.head
											_lowerCamelCase	:     Tuple       =       new_node
							else:
											_lowerCamelCase	:     Union[str, Any]       =       self.head
											for _ in range(index - 1    ):
															_lowerCamelCase	:     Tuple       =       temp.next
											_lowerCamelCase	:     Any       =       temp.next
											_lowerCamelCase	:     str       =       new_node
											if index == len(self    ) - 1:  # insert at tail
															_lowerCamelCase	:     List[Any]       =       new_node
			def    A_       (    self    ):
							return self.delete_nth(0    )
			def    A_       (    self    ):
							return self.delete_nth(len(self    ) - 1    )
			def    A_       (    self    , lowercase = 0    ):
							if not 0 <= index < len(self    ):
											raise IndexError('list index out of range.'    )
							_lowerCamelCase	:     Optional[Any]       =       self.head
							if self.head == self.tail:  # just one node
											_lowerCamelCase	:     Optional[Any]       =       None
							elif index == 0:  # delete head node
											_lowerCamelCase	:     List[Any]       =       self.tail.next.next
											_lowerCamelCase	:     Optional[Any]       =       self.head.next
							else:
											_lowerCamelCase	:     Union[str, Any]       =       self.head
											for _ in range(index - 1    ):
															_lowerCamelCase	:     str       =       temp.next
											_lowerCamelCase	:     Union[str, Any]       =       temp.next
											_lowerCamelCase	:     Dict       =       temp.next.next
											if index == len(self    ) - 1:  # delete at tail
															_lowerCamelCase	:     Union[str, Any]       =       temp
							return delete_node.data






			def    A_       (    self    ):
							return len(self    ) == 0







def 	_snake_case     (							):
				_lowerCamelCase	:     List[Any]       =       CircularLinkedList()
				assert len(lowercase__						) == 0
				assert circular_linked_list.is_empty() is True
				assert str(lowercase__						) == ""

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

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

				try:
								circular_linked_list.delete_nth(-1						)
								raise AssertionError
				except IndexError:
								assert True

				try:
								circular_linked_list.delete_nth(0						)
								raise AssertionError
				except IndexError:
								assert True

				assert circular_linked_list.is_empty() is True
				for i in range(5						):
								assert len(lowercase__						) == i
								circular_linked_list.insert_nth(lowercase__				,       i + 1						)
				assert str(lowercase__						) == "->".join(str(lowercase__						) for i in range(1				,       6						)						)

				circular_linked_list.insert_tail(6						)
				assert str(lowercase__						) == "->".join(str(lowercase__						) for i in range(1				,       7						)						)
				circular_linked_list.insert_head(0						)
				assert str(lowercase__						) == "->".join(str(lowercase__						) for i in range(0				,       7						)						)

				assert circular_linked_list.delete_front() == 0
				assert circular_linked_list.delete_tail() == 6
				assert str(lowercase__						) == "->".join(str(lowercase__						) for i in range(1				,       6						)						)
				assert circular_linked_list.delete_nth(2						) == 3

				circular_linked_list.insert_nth(2				,       3						)
				assert str(lowercase__						) == "->".join(str(lowercase__						) for i in range(1				,       6						)						)

				assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
			import doctest

			doctest.testmod()





"""simple docstring"""






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


lowercase__			=		logging.get_logger(__name__)

lowercase__			=		{"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""}






class lowerCAmelCase__      (	lowercase		):






			'''simple docstring'''



			lowerCamelCase__ =     """openai-gpt"""
			lowerCamelCase__ =     {
			    """max_position_embeddings""": """n_positions""",
			    """hidden_size""": """n_embd""",
			    """num_attention_heads""": """n_head""",
			    """num_hidden_layers""": """n_layer""",
			}
			def __init__(    self    , lowercase=40478    , lowercase=512    , lowercase=768    , lowercase=12    , lowercase=12    , lowercase="gelu"    , lowercase=0.1    , lowercase=0.1    , lowercase=0.1    , lowercase=1E-5    , lowercase=0.02    , lowercase="cls_index"    , lowercase=True    , lowercase=None    , lowercase=True    , lowercase=0.1    , **lowercase    , ):
							_lowerCamelCase	:     Tuple       =       vocab_size
							_lowerCamelCase	:     List[str]       =       n_positions
							_lowerCamelCase	:     Tuple       =       n_embd
							_lowerCamelCase	:     Optional[int]       =       n_layer
							_lowerCamelCase	:     List[Any]       =       n_head
							_lowerCamelCase	:     Dict       =       afn
							_lowerCamelCase	:     Union[str, Any]       =       resid_pdrop
							_lowerCamelCase	:     Dict       =       embd_pdrop
							_lowerCamelCase	:     List[Any]       =       attn_pdrop
							_lowerCamelCase	:     Any       =       layer_norm_epsilon
							_lowerCamelCase	:     List[Any]       =       initializer_range
							_lowerCamelCase	:     List[Any]       =       summary_type
							_lowerCamelCase	:     List[str]       =       summary_use_proj
							_lowerCamelCase	:     Tuple       =       summary_activation
							_lowerCamelCase	:     int       =       summary_first_dropout
							_lowerCamelCase	:     str       =       summary_proj_to_labels
							super().__init__(**lowercase    )