import inspect
import unittest






class 		_lowerCamelCase		( unittest.TestCase     ):
    def     UpperCamelCase_					(	self )							->       Any:
     try:
      import diffusers  # noqa: F401
     except ImportError:
      assert False



    def     UpperCamelCase_					(	self )							->       List[str]:
     import diffusers
     from diffusers.dependency_versions_table import deps

     SCREAMING_SNAKE_CASE__: Tuple=   inspect.getmembers(lowerCAmelCase			,			inspect.isclass )

     for cls_name, cls_module in all_classes:
      if "dummy_" in cls_module.__module__:
       for backend in cls_module._backends:
        if backend == "k_diffusion":
         SCREAMING_SNAKE_CASE__: Optional[int]=   '''k-diffusion'''
        elif backend == "invisible_watermark":
         SCREAMING_SNAKE_CASE__: int=   '''invisible-watermark'''
        assert backend in deps, f'{backend} is not in the deps table!'



"""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_            =    128
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_            =    2000
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) * 1000 / max_iters))



