





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


snake_case__      :							List[Any]									=  logging.get_logger(__name__)

snake_case__      :							str									=  {
    'facebook/opt-125m': 'https://huggingface.co/facebook/opt-125m/blob/main/config.json',
    'facebook/opt-350m': 'https://huggingface.co/facebook/opt-350m/blob/main/config.json',
    'facebook/opt-1.3b': 'https://huggingface.co/facebook/opt-1.3b/blob/main/config.json',
    'facebook/opt-2.7b': 'https://huggingface.co/facebook/opt-2.7b/blob/main/config.json',
    'facebook/opt-6.7b': 'https://huggingface.co/facebook/opt-6.7b/blob/main/config.json',
    'facebook/opt-13b': 'https://huggingface.co/facebook/opt-13b/blob/main/config.json',
}





class A_      (    A_     ):
			lowerCAmelCase__       =				'''opt'''
			lowerCAmelCase__       =				['''past_key_values''']




			def __init__(self			:Tuple					,     _UpperCamelCase			:List[Any]=5_0272					,     _UpperCamelCase			:List[Any]=768					,     _UpperCamelCase			:List[str]=12					,     _UpperCamelCase			:List[Any]=3072					,     _UpperCamelCase			:Dict=2048					,     _UpperCamelCase			:List[Any]=True					,     _UpperCamelCase			:Dict=False					,     _UpperCamelCase			:Any=None					,     _UpperCamelCase			:Optional[Any]=0.1					,     _UpperCamelCase			:Optional[Any]=0.0					,     _UpperCamelCase			:List[str]=12					,     _UpperCamelCase			:List[Any]="relu"					,     _UpperCamelCase			:List[Any]=0.0					,     _UpperCamelCase			:Dict=0.0_2					,     _UpperCamelCase			:List[str]=True					,     _UpperCamelCase			:Optional[Any]=1					,     _UpperCamelCase			:Union[str, Any]=2					,     _UpperCamelCase			:Any=2					,     _UpperCamelCase			:Optional[int]=True					,     _UpperCamelCase			:Optional[Any]=True					,     **_UpperCamelCase			:Union[str, Any]					,     )->      str:
									super().__init__(
									    pad_token_id=_UpperCamelCase					,     bos_token_id=_UpperCamelCase					,     eos_token_id=_UpperCamelCase					,     **_UpperCamelCase					,     )
									__A      =       vocab_size
									__A      =       max_position_embeddings
									__A      =       num_attention_heads
									__A      =       word_embed_proj_dim if word_embed_proj_dim is not None else hidden_size
									__A      =       ffn_dim
									__A      =       hidden_size
									__A      =       num_hidden_layers
									__A      =       dropout
									__A      =       attention_dropout
									__A      =       activation_function
									__A      =       init_std
									__A      =       layerdrop
									__A      =       use_cache
									__A      =       do_layer_norm_before
									# We keep these variables at `True` for backward compatibility.
									__A      =       enable_bias
									__A      =       layer_norm_elementwise_affine

									# Note that the only purpose of `_remove_final_layer_norm` is to keep backward compatibility
									# with checkpoints that have been fine-tuned before transformers v4.20.1
									# see https://github.com/facebookresearch/metaseq/pull/164
									__A      =       _remove_final_layer_norm












class A_      :




   def __init__(self			:Union[str, Any]				)->      None:
         # numbermap keys are the number and its values are lists of indexes sorted
         # in ascending order
         __A      =       {}
         # indexmap keys are an index and it's values are the number at that index
         __A      =       {}




   def _lowerCAmelCase   (self			:Any					,     _UpperCamelCase			:list | str | range					,     _UpperCamelCase			:int				)->      list[int]:
         if isinstance(_UpperCamelCase					,     (range, str)				):
               __A      =       list(_UpperCamelCase				)
         elif not isinstance(_UpperCamelCase					,     _UpperCamelCase				):
               raise TypeError(
                   '''binary_search_delete() only accepts either a list, range or str'''				)

         __A      =       0
         __A      =       len(_UpperCamelCase				) - 1

         while low <= high:
               __A      =       (low + high) // 2
               if array[mid] == item:
                     array.pop(_UpperCamelCase				)
                     return array
               elif array[mid] < item:
                     __A      =       mid + 1
               else:
                     __A      =       mid - 1
         raise ValueError(
             '''Either the item is not in the array or the array was unsorted'''				)




   def _lowerCAmelCase   (self			:Optional[Any]					,     _UpperCamelCase			:list | str | range					,     _UpperCamelCase			:int				)->      list[int]:
         if isinstance(_UpperCamelCase					,     (range, str)				):
               __A      =       list(_UpperCamelCase				)
         elif not isinstance(_UpperCamelCase					,     _UpperCamelCase				):
               raise TypeError(
                   '''binary_search_insert() only accepts either a list, range or str'''				)

         __A      =       0
         __A      =       len(_UpperCamelCase				) - 1

         while low <= high:
               __A      =       (low + high) // 2
               if array[mid] == index:
                     # If the item already exists in the array,
                     # insert it after the existing item
                     array.insert(mid + 1					,     _UpperCamelCase				)
                     return array
               elif array[mid] < index:
                     __A      =       mid + 1
               else:
                     __A      =       mid - 1

        # If the item doesn't exist in the array, insert it at the appropriate position
         array.insert(_UpperCamelCase					,     _UpperCamelCase				)
         return array




   def _lowerCAmelCase   (self			:Union[str, Any]					,     _UpperCamelCase			:int					,     _UpperCamelCase			:int				)->      None:
         # Remove previous index
         if index in self.indexmap:
               __A      =       self.indexmap[index]
               if len(self.numbermap[n]				) == 1:
                     del self.numbermap[n]
               else:
                     __A      =       self.binary_search_delete(self.numbermap[n]					,     _UpperCamelCase				)

        # Set new index
         __A      =       number

         # Number not seen before or empty so insert number value
         if number not in self.numbermap:
               __A      =       [index]

         # Here we need to perform a binary search insertion in order to insert
         # The item in the correct place
         else:
               __A      =       self.binary_search_insert(
                   self.numbermap[number]					,     _UpperCamelCase				)






   def _lowerCAmelCase   (self			:List[Any]					,     _UpperCamelCase			:int				)->      int:
         return self.numbermap.get(_UpperCamelCase					,     [-1]				)[0]


if __name__ == "__main__":
       import doctest

       doctest.testmod()





