




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


a_			=     logging.get_logger(__name__)

a_			=     {
    "edbeeching/decision-transformer-gym-hopper-medium": (
        "https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/main/config.json"
    ),
    # See all DecisionTransformer models at https://huggingface.co/models?filter=decision_transformer
}

class  _lowerCamelCase						(			UpperCamelCase__   ):

      """simple docstring"""

      lowerCAmelCase__			: Dict    =					"decision_transformer"
      lowerCAmelCase__			: int    =					["past_key_values"]
      lowerCAmelCase__			: Optional[int]    =					{
          "max_position_embeddings": "n_positions",
          "num_attention_heads": "n_head",
          "num_hidden_layers": "n_layer",
      }







      def __init__(     self					: str ,       snake_case					: List[Any]=17 ,       snake_case					: Optional[int]=4 ,       snake_case					: str=128 ,       snake_case					: int=4096 ,       snake_case					: Any=True ,       snake_case					: int=1 ,       snake_case					: int=1024 ,       snake_case					: int=3 ,       snake_case					: Union[str, Any]=1 ,       snake_case					: int=None ,       snake_case					: str="relu" ,       snake_case					: Union[str, Any]=0.1 ,       snake_case					: Tuple=0.1 ,       snake_case					: Optional[int]=0.1 ,       snake_case					: Optional[int]=1E-5 ,       snake_case					: int=0.02 ,       snake_case					: Any=True ,       snake_case					: Dict=True ,       snake_case					: Optional[int]=50256 ,       snake_case					: Dict=50256 ,       snake_case					: str=False ,       snake_case					: Optional[Any]=False ,       **snake_case					: Any ,       ):
          __UpperCamelCase  		=						state_dim
          __UpperCamelCase  		=						act_dim
          __UpperCamelCase  		=						hidden_size
          __UpperCamelCase  		=						max_ep_len
          __UpperCamelCase  		=						action_tanh
          __UpperCamelCase  		=						vocab_size
          __UpperCamelCase  		=						n_positions
          __UpperCamelCase  		=						n_layer
          __UpperCamelCase  		=						n_head
          __UpperCamelCase  		=						n_inner
          __UpperCamelCase  		=						activation_function
          __UpperCamelCase  		=						resid_pdrop
          __UpperCamelCase  		=						embd_pdrop
          __UpperCamelCase  		=						attn_pdrop
          __UpperCamelCase  		=						layer_norm_epsilon
          __UpperCamelCase  		=						initializer_range
          __UpperCamelCase  		=						scale_attn_weights
          __UpperCamelCase  		=						use_cache
          __UpperCamelCase  		=						scale_attn_by_inverse_layer_idx
          __UpperCamelCase  		=						reorder_and_upcast_attn

          __UpperCamelCase  		=						bos_token_id
          __UpperCamelCase  		=						eos_token_id

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












import os
import time

import numpy as np
import onnxruntime as ort


a_   		=     "1"
a_   		=     "0"
a_   		=     "1"

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

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






