






'''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_					   =				1_2_8
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_					   =				2_0_0_0
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) * 1_0_0_0 / max_iters))












import requests






def      _snake_case     (__lowercase     ,   __lowercase):
   UpperCamelCase_						=  {'Content-Type': 'application/json'}
   UpperCamelCase_						=  requests.post(__lowercase     ,   json={'text': message_body}     ,   headers=__lowercase)
   if response.status_code != 200:
      UpperCamelCase_						=  (
          'Request to slack returned an error '
          f"""{response.status_code}, the response is:\n{response.text}"""
      )
      raise ValueError(__lowercase)


if __name__ == "__main__":
 # Set the slack url to the one provided by Slack when you create the webhook at
 # https://my.slack.com/services/new/incoming-webhook/
 send_slack_message("""<YOUR MESSAGE BODY>""", """<SLACK CHANNEL URL>""")





