



"""simple docstring"""




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


_lowerCAmelCase    : str							=							logging.get_logger(__name__)

_lowerCAmelCase    : Optional[int]							=							{
    "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json",
    "tiiuae/falcon-7b": "https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json",
}






class      UpperCAmelCase_  (    _UpperCamelCase						):
      __SCREAMING_SNAKE_CASE						:       Optional[int]								=			'falcon'
      __SCREAMING_SNAKE_CASE						:       Optional[int]								=			['past_key_values']



      def __init__(					self					:     List[Any]					,     A					:     int=6_5_0_2_4					,     A					:     int=4_5_4_4					,     A					:     Tuple=3_2					,     A					:     Tuple=7_1					,     A					:     Tuple=1e-5					,     A					:     int=0.02					,     A					:     int=True					,     A					:     Dict=0.0					,     A					:     Any=0.0					,     A					:     str=None					,     A					:     Optional[int]=False					,     A					:     Union[str, Any]=False					,     A					:     Optional[Any]=True					,     A					:     Tuple=True					,     A					:     List[str]=False					,     A					:     List[Any]=1_1					,     A					:     Dict=1_1					,     **A					:     str					,     ):
           _UpperCAmelCase      :     Any        =   vocab_size
           # Backward compatibility with n_embed kwarg
           _UpperCAmelCase      :     Tuple        =   kwargs.pop("n_embed"					,     A						)
           _UpperCAmelCase      :     Dict        =   hidden_size if n_embed is None else n_embed
           _UpperCAmelCase      :     int        =   num_hidden_layers
           _UpperCAmelCase      :     Optional[int]        =   num_attention_heads
           _UpperCAmelCase      :     List[Any]        =   layer_norm_epsilon
           _UpperCAmelCase      :     Optional[Any]        =   initializer_range
           _UpperCAmelCase      :     List[str]        =   use_cache
           _UpperCAmelCase      :     Dict        =   hidden_dropout
           _UpperCAmelCase      :     Any        =   attention_dropout

           _UpperCAmelCase      :     Tuple        =   bos_token_id
           _UpperCAmelCase      :     Tuple        =   eos_token_id
           _UpperCAmelCase      :     str        =   num_attention_heads if num_kv_heads is None else num_kv_heads
           _UpperCAmelCase      :     Union[str, Any]        =   alibi
           _UpperCAmelCase      :     List[Any]        =   new_decoder_architecture
           _UpperCAmelCase      :     Dict        =   multi_query  # Ignored when new_decoder_architecture is True
           _UpperCAmelCase      :     int        =   parallel_attn
           _UpperCAmelCase      :     List[Any]        =   bias

           super().__init__(bos_token_id=A					,     eos_token_id=A					,     **A						)



      @property
      def 						snake_case_ (					self					:     Optional[Any]						):
           return self.hidden_size // self.num_attention_heads



      @property
      def 						snake_case_ (					self					:     int						):
           return not self.alibi





"""simple docstring"""




from collections.abc import Callable






class      UpperCAmelCase_  :



      def __init__(					self					:     Dict					,     A					:     Callable | None = None						):
           # Stores actual heap items.
           _UpperCAmelCase      :     list        =   []
           # Stores indexes of each item for supporting updates and deletion.
           _UpperCAmelCase      :     dict        =   {}
           # Stores current size of heap.
           _UpperCAmelCase      :     Tuple        =   0
           # Stores function used to evaluate the score of an item on which basis ordering
           # will be done.
           _UpperCAmelCase      :     Any        =   key or (lambda A						: x)



      def 						snake_case_ (					self					:     List[Any]					,     A					:     int						):
           return int((i - 1) / 2						) if i > 0 else None



      def 						snake_case_ (					self					:     List[Any]					,     A					:     int						):
           _UpperCAmelCase      :     Tuple        =   int(2 * i + 1						)
           return left if 0 < left < self.size else None



      def 						snake_case_ (					self					:     List[Any]					,     A					:     int						):
           _UpperCAmelCase      :     Tuple        =   int(2 * i + 2						)
           return right if 0 < right < self.size else None



      def 						snake_case_ (					self					:     Optional[int]					,     A					:     int					,     A					:     int						):
           _UpperCAmelCase    ,	_UpperCAmelCase      :     int        =   (
               self.pos_map[self.arr[j][0]],
               self.pos_map[self.arr[i][0]],
           )
           # Then swap the items in the list.
           _UpperCAmelCase    ,	_UpperCAmelCase      :     Any        =   self.arr[j], self.arr[i]



      def 						snake_case_ (					self					:     List[str]					,     A					:     int					,     A					:     int						):
           return self.arr[i][1] < self.arr[j][1]



      def 						snake_case_ (					self					:     Dict					,     A					:     int						):
           _UpperCAmelCase      :     str        =   self._left(A						)
           _UpperCAmelCase      :     str        =   self._right(A						)
           _UpperCAmelCase      :     List[Any]        =   i

           if left is not None and not self._cmp(A					,     A						):
                _UpperCAmelCase      :     Optional[int]        =   left
           if right is not None and not self._cmp(A					,     A						):
                _UpperCAmelCase      :     Any        =   right

           return valid_parent



      def 						snake_case_ (					self					:     Tuple					,     A					:     int						):
           _UpperCAmelCase      :     Tuple        =   self._parent(A						)
           while parent is not None and not self._cmp(A					,     A						):
                self._swap(A					,     A						)
                _UpperCAmelCase    ,	_UpperCAmelCase      :     Dict        =   parent, self._parent(A						)



      def 						snake_case_ (					self					:     Optional[int]					,     A					:     int						):
           _UpperCAmelCase      :     Tuple        =   self._get_valid_parent(A						)
           while valid_parent != index:
                self._swap(A					,     A						)
                _UpperCAmelCase    ,	_UpperCAmelCase      :     Optional[Any]        =   valid_parent, self._get_valid_parent(A						)



      def 						snake_case_ (					self					:     Dict					,     A					:     int					,     A					:     int						):
           if item not in self.pos_map:
                return
           _UpperCAmelCase      :     Any        =   self.pos_map[item]
           _UpperCAmelCase      :     Optional[int]        =   [item, self.key(A						)]
           # Make sure heap is right in both up and down direction.
           # Ideally only one of them will make any change.
           self._heapify_up(A						)
           self._heapify_down(A						)



      def 						snake_case_ (					self					:     List[str]					,     A					:     int						):
           if item not in self.pos_map:
                return
           _UpperCAmelCase      :     str        =   self.pos_map[item]
           del self.pos_map[item]
           _UpperCAmelCase      :     Tuple        =   self.arr[self.size - 1]
           _UpperCAmelCase      :     List[Any]        =   index
           self.size -= 1
           # Make sure heap is right in both up and down direction. Ideally only one
           # of them will make any change- so no performance loss in calling both.
           if self.size > index:
                self._heapify_up(A						)
                self._heapify_down(A						)



      def 						snake_case_ (					self					:     Any					,     A					:     int					,     A					:     int						):
           _UpperCAmelCase      :     Any        =   len(self.arr						)
           if arr_len == self.size:
                self.arr.append([item, self.key(A						)]						)
           else:
                _UpperCAmelCase      :     Any        =   [item, self.key(A						)]
           _UpperCAmelCase      :     List[Any]        =   self.size
           self.size += 1
           self._heapify_up(self.size - 1						)



      def 						snake_case_ (					self					:     Tuple						):
           return self.arr[0] if self.size else None



      def 						snake_case_ (					self					:     Any						):
           _UpperCAmelCase      :     Dict        =   self.get_top()
           if top_item_tuple:
                self.delete_item(top_item_tuple[0]						)
           return top_item_tuple







def 						__snake_case						(				)  ->       None:





     '''simple docstring'''



if __name__ == "__main__":
 import doctest

 doctest.testmod()
