




import os
import time

import numpy as np
import onnxruntime as ort


lowerCAmelCase_					    = """1"""
lowerCAmelCase_					    = """0"""
lowerCAmelCase_					    = """1"""

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

lowerCAmelCase_					    = 1_28
lowerCAmelCase_					    = 1
lowerCAmelCase_					    = np.ones((batch, sequence), dtype=np.intaa)
lowerCAmelCase_					    = np.ones((batch, sequence), dtype=np.intaa)
lowerCAmelCase_					    = 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...""")
lowerCAmelCase_					    = time.time()
lowerCAmelCase_					    = 20_00
lowerCAmelCase_					    = {}
for iter in range(max_iters):
     lowerCAmelCase_					    = 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 collections import Counter
from timeit import timeit



def      __lowerCAmelCase			(					UpperCamelCase = ""	,      )     ->	bool:
  return sum(c % 2 for c in Counter(input_str.replace(''' '''	,      ''''''      ).lower()      ).values()      ) < 2



def      __lowerCAmelCase			(					UpperCamelCase = ""      )     ->	bool:
  if len(UpperCamelCase      ) == 0:
    return True
  lowerCAmelCase__				:  str		       =     input_str.replace(''' '''	,      ''''''      ).lower()
  # character_freq_dict: Stores the frequency of every character in the input string
  lowerCAmelCase__				:  dict[str, int]		       =     {}

  for character in lower_case_input_str:
    lowerCAmelCase__				:  int		       =     character_freq_dict.get(UpperCamelCase	,      0      ) + 1
  lowerCAmelCase__				:  Any		       =     0

  for character_count in character_freq_dict.values():
    if character_count % 2:
      odd_char += 1
  if odd_char > 1:
    return False
  return True



def      __lowerCAmelCase			(					UpperCamelCase = ""      )     ->	None:
  print('''\nFor string = '''	,      UpperCamelCase	,      ''':'''      )
  print(
      '''> can_string_be_rearranged_as_palindrome_counter()'''	,      '''\tans ='''	,      can_string_be_rearranged_as_palindrome_counter(UpperCamelCase      )	,      '''\ttime ='''	,      timeit(
          '''z.can_string_be_rearranged_as_palindrome_counter(z.check_str)'''	,      setup='''import __main__ as z'''	,      )	,      '''seconds'''	,      )
  print(
      '''> can_string_be_rearranged_as_palindrome()'''	,      '''\tans ='''	,      can_string_be_rearranged_as_palindrome(UpperCamelCase      )	,      '''\ttime ='''	,      timeit(
          '''z.can_string_be_rearranged_as_palindrome(z.check_str)'''	,      setup='''import __main__ as z'''	,      )	,      '''seconds'''	,      )


if __name__ == "__main__":
     lowerCAmelCase_					    = input(
         """Enter string to determine if it can be rearranged as a palindrome or not: """
     ).strip()
     benchmark(check_str)
     lowerCAmelCase_					    = can_string_be_rearranged_as_palindrome_counter(check_str)
     print(F"""{check_str} can {"" if status else "not "}be rearranged as a palindrome""")

