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


UpperCAmelCase_			    =							logging.get_logger(__name__)

UpperCAmelCase_			    =							{
    '''tanreinama/GPTSAN-2.8B-spout_is_uniform''': (
        '''https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json'''
    ),
}




class  __magic_name__  (		__a    ):





   """simple docstring"""




   lowerCAmelCase      :    str  			=   '''gptsan-japanese'''
   lowerCAmelCase      :    Dict  			=   [
       '''past_key_values''',
   ]
   lowerCAmelCase      :    Dict  			=   {
       '''hidden_size''': '''d_model''',
       '''num_attention_heads''': '''num_heads''',
       '''num_hidden_layers''': '''num_layers''',
   }



   def __init__(	self					:  List[str]		,  _lowercase					:  str=36_000		,  _lowercase					:  List[str]=1_280		,  _lowercase					:  Optional[Any]=1_024		,  _lowercase					:  str=8_192		,  _lowercase					:  Dict=4_096		,  _lowercase					:  int=128		,  _lowercase					:  Optional[int]=10		,  _lowercase					:  str=0		,  _lowercase					:  str=16		,  _lowercase					:  Dict=16		,  _lowercase					:  Optional[int]=128		,  _lowercase					:  Any=0.0		,  _lowercase					:  str=1E-5		,  _lowercase					:  Optional[Any]=False		,  _lowercase					:  List[str]=0.0		,  _lowercase					:  Optional[Any]="float32"		,  _lowercase					:  str=False		,  _lowercase					:  Dict=False		,  _lowercase					:  List[str]=False		,  _lowercase					:  List[str]=0.002		,  _lowercase					:  int=False		,  _lowercase					:  Any=True		,  _lowercase					:  Optional[int]=35_998		,  _lowercase					:  int=35_995		,  _lowercase					:  Any=35_999		,  **_lowercase					:  Any		,  ):



    """simple docstring"""



    _UpperCamelCase:     Tuple							= vocab_size
    _UpperCamelCase:     str							= max_position_embeddings
    _UpperCamelCase:     str							= d_model
    _UpperCamelCase:     Any							= d_ff
    _UpperCamelCase:     Optional[int]							= d_ext
    _UpperCamelCase:     Any							= d_spout
    _UpperCamelCase:     List[Any]							= num_switch_layers
    _UpperCamelCase:     List[Any]							= num_ext_layers
    _UpperCamelCase:     Tuple							= num_switch_layers + num_ext_layers
    _UpperCamelCase:     Any							= num_heads
    _UpperCamelCase:     Optional[Any]							= num_experts
    _UpperCamelCase:     str							= expert_capacity
    _UpperCamelCase:     List[str]							= dropout_rate
    _UpperCamelCase:     List[str]							= layer_norm_epsilon
    _UpperCamelCase:     Optional[Any]							= router_bias
    _UpperCamelCase:     Optional[int]							= router_jitter_noise
    _UpperCamelCase:     str							= router_dtype
    _UpperCamelCase:     Tuple							= router_ignore_padding_tokens
    _UpperCamelCase:     Union[str, Any]							= output_hidden_states
    _UpperCamelCase:     Dict							= output_attentions
    _UpperCamelCase:     Optional[int]							= initializer_factor
    _UpperCamelCase:     Union[str, Any]							= output_router_logits
    _UpperCamelCase:     int							= use_cache

    super().__init__(
        separator_token_id=_lowercase		,  pad_token_id=_lowercase		,  eos_token_id=_lowercase		,  **_lowercase		,  )
import os
import time

import numpy as np
import onnxruntime as ort


UpperCAmelCase_			    =							'''1'''
UpperCAmelCase_			    =							'''0'''
UpperCAmelCase_			    =							'''1'''

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

UpperCAmelCase_			    =							1_2_8
UpperCAmelCase_			    =							1
UpperCAmelCase_			    =							np.ones((batch, sequence), dtype=np.intaa)
UpperCAmelCase_			    =							np.ones((batch, sequence), dtype=np.intaa)
UpperCAmelCase_			    =							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...''')
UpperCAmelCase_			    =							time.time()
UpperCAmelCase_			    =							2_0_0_0
UpperCAmelCase_			    =							{}
for iter in range(max_iters):
  UpperCAmelCase_			    =							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) * 1_0_0_0 / max_iters))