


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


snake_case__      =						logging.get_logger(__name__)

snake_case__      =						{
    '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''',
    # See all CANINE models at https://huggingface.co/models?filter=canine
}


class 					lowerCAmelCase_ (       _a):
						lowerCamelCase_         =     'canine'




						def __init__(	self						:   int   ,     __A						:   Tuple=768   ,     __A						:   str=12   ,     __A						:   str=12   ,     __A						:   str=3072   ,     __A						:   Any="gelu"   ,     __A						:   Optional[int]=0.1   ,     __A						:   Any=0.1   ,     __A						:   Any=16384   ,     __A						:   Union[str, Any]=16   ,     __A						:   Optional[Any]=0.02   ,     __A						:   Optional[int]=1E-12   ,     __A						:   str=0   ,     __A						:   str=0Xe_000   ,     __A						:   Tuple=0Xe_001   ,     __A						:   Optional[int]=4   ,     __A						:   List[str]=4   ,     __A						:   Optional[Any]=8   ,     __A						:   Optional[int]=16384   ,     __A						:   Tuple=128   ,     **__A						:   List[Any]   ,     )      ->Dict:






									"""simple docstring"""






									super().__init__(pad_token_id=__A   ,     bos_token_id=__A   ,     eos_token_id=__A   ,     **__A						)

									a__ :Tuple						  =    max_position_embeddings
									a__ :Dict						  =    hidden_size
									a__ :List[Any]						  =    num_hidden_layers
									a__ :Tuple						  =    num_attention_heads
									a__ :Dict						  =    intermediate_size
									a__ :str						  =    hidden_act
									a__ :Optional[int]						  =    hidden_dropout_prob
									a__ :List[Any]						  =    attention_probs_dropout_prob
									a__ :Optional[Any]						  =    initializer_range
									a__ :Tuple						  =    type_vocab_size
									a__ :List[str]						  =    layer_norm_eps

									# Character config:
									a__ :Tuple						  =    downsampling_rate
									a__ :List[Any]						  =    upsampling_kernel_size
									a__ :int						  =    num_hash_functions
									a__ :List[str]						  =    num_hash_buckets
									a__ :List[str]						  =    local_transformer_stride






import os
import time

import numpy as np
import onnxruntime as ort


snake_case__			 =						'''1'''
snake_case__			 =						'''0'''
snake_case__			 =						'''1'''

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

snake_case__			 =						128
snake_case__			 =						1
snake_case__			 =						np.ones((batch, sequence), dtype=np.intaa)
snake_case__			 =						np.ones((batch, sequence), dtype=np.intaa)
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...''')
snake_case__			 =						time.time()
snake_case__			 =						2000
snake_case__			 =						{}
for iter in range(max_iters):
		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))


