


import os
import time

import numpy as np
import onnxruntime as ort


snake_case				:    List[Any]       				=     '''1'''
snake_case				:    List[str]       				=     '''0'''
snake_case				:    int       				=     '''1'''

snake_case				:    Optional[Any]       				=     ort.SessionOptions()
snake_case				:    Union[str, Any]       				=     ort.GraphOptimizationLevel.ORT_DISABLE_ALL
print('''Create inference session...''')
snake_case				:    List[str]       				=     ['''TensorrtExecutionProvider''', '''CUDAExecutionProvider''']
snake_case				:    List[str]       				=     ort.InferenceSession('''model.onnx''', sess_options=sess_opt, providers=execution_provider)
snake_case				:    Optional[Any]       				=     ort.RunOptions()

snake_case				:    int       				=     1_28
snake_case				:    Optional[int]       				=     1
snake_case				:    Optional[int]       				=     np.ones((batch, sequence), dtype=np.intaa)
snake_case				:    Union[str, Any]       				=     np.ones((batch, sequence), dtype=np.intaa)
snake_case				:    Any       				=     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				:    int       				=     time.time()
snake_case				:    Tuple       				=     20_00
snake_case				:    Dict       				=     {}
for iter in range(max_iters):
     snake_case				:    List[str]       				=     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) * 10_00 / max_iters))







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


_A   =     logging.get_logger(__name__)

_A   =     {
    # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert
}





class 	_lowerCAmelCase					(	__a       ):
				_lowercase					='''megatron-bert'''




				def __init__(					self				,				_UpperCamelCase=29_056				,				_UpperCamelCase=1_024				,				_UpperCamelCase=24				,				_UpperCamelCase=16				,				_UpperCamelCase=4_096				,				_UpperCamelCase="gelu"				,				_UpperCamelCase=0.1				,				_UpperCamelCase=0.1				,				_UpperCamelCase=512				,				_UpperCamelCase=2				,				_UpperCamelCase=0.02				,				_UpperCamelCase=1e-1_2				,				_UpperCamelCase=0				,				_UpperCamelCase="absolute"				,				_UpperCamelCase=True				,				**_UpperCamelCase				,				)				->      int:
							super().__init__(pad_token_id=_UpperCamelCase				,				**_UpperCamelCase     )

							lowerCAmelCase_						=	vocab_size
							lowerCAmelCase_						=	hidden_size
							lowerCAmelCase_						=	num_hidden_layers
							lowerCAmelCase_						=	num_attention_heads
							lowerCAmelCase_						=	hidden_act
							lowerCAmelCase_						=	intermediate_size
							lowerCAmelCase_						=	hidden_dropout_prob
							lowerCAmelCase_						=	attention_probs_dropout_prob
							lowerCAmelCase_						=	max_position_embeddings
							lowerCAmelCase_						=	type_vocab_size
							lowerCAmelCase_						=	initializer_range
							lowerCAmelCase_						=	layer_norm_eps
							lowerCAmelCase_						=	position_embedding_type
							lowerCAmelCase_						=	use_cache



