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


A						=			logging.get_logger(__name__)

A						=			{
    '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     lowerCAmelCase__     (				SCREAMING_SNAKE_CASE_			):


		'''simple docstring'''






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

				_lowerCamelCase				   =  bos_token_id
				_lowerCamelCase				   =  eos_token_id
				_lowerCamelCase				   =  num_attention_heads if num_kv_heads is None else num_kv_heads
				_lowerCamelCase				   =  alibi
				_lowerCamelCase				   =  new_decoder_architecture
				_lowerCamelCase				   =  multi_query  # Ignored when new_decoder_architecture is True
				_lowerCamelCase				   =  parallel_attn
				_lowerCamelCase				   =  bias

				super().__init__(bos_token_id=lowercase_     ,  eos_token_id=lowercase_     ,  **lowercase_		)
		@property
		def   _snake_case       (       self     :     int		)      ->	List[Any]:
				return self.hidden_size // self.num_attention_heads



		@property
		def   _snake_case       (       self     :     int		)      ->	List[str]:
				return not self.alibi

"""simple docstring"""

import os
import time

import numpy as np
import onnxruntime as ort


SCREAMING_SNAKE_CASE_            =    '''1'''
SCREAMING_SNAKE_CASE_            =    '''0'''
SCREAMING_SNAKE_CASE_            =    '''1'''

SCREAMING_SNAKE_CASE_            =    ort.SessionOptions()
SCREAMING_SNAKE_CASE_            =    ort.GraphOptimizationLevel.ORT_DISABLE_ALL
print('''Create inference session...''')
SCREAMING_SNAKE_CASE_            =    ['''TensorrtExecutionProvider''', '''CUDAExecutionProvider''']
SCREAMING_SNAKE_CASE_            =    ort.InferenceSession('''model.onnx''', sess_options=sess_opt, providers=execution_provider)
SCREAMING_SNAKE_CASE_            =    ort.RunOptions()

SCREAMING_SNAKE_CASE_            =    128
SCREAMING_SNAKE_CASE_            =    1
SCREAMING_SNAKE_CASE_            =    np.ones((batch, sequence), dtype=np.intaa)
SCREAMING_SNAKE_CASE_            =    np.ones((batch, sequence), dtype=np.intaa)
SCREAMING_SNAKE_CASE_            =    np.ones((batch, sequence), dtype=np.intaa)

print('''Warm up phase...''')
sess.run(
    None,
    {
        sess.get_inputs()[0].name: input_ids,
        sess.get_inputs()[1].name: attention_mask,
        sess.get_inputs()[2].name: token_type_ids,
    },
    run_options=run_opt,
)

print('''Start inference...''')
SCREAMING_SNAKE_CASE_            =    time.time()
SCREAMING_SNAKE_CASE_            =    2000
SCREAMING_SNAKE_CASE_            =    {}
for iter in range(max_iters):
   SCREAMING_SNAKE_CASE_            =    sess.run(
       None,
       {
           sess.get_inputs()[0].name: input_ids,
           sess.get_inputs()[1].name: attention_mask,
           sess.get_inputs()[2].name: token_type_ids,
       },
       run_options=run_opt,
   )
print('''Average Inference Time = {:.3f} ms'''.format((time.time() - start_time) * 1000 / max_iters))



