class_docstr: This is the accelerated model for tensorflow and onnxruntime.
class_docstr_tok: ["This","is","the","accelerated","model","for","tensorflow","and","onnxruntime","."]
docstr: Create a ONNX Runtime model from tensorflow.
  
  :param model: 1. Keras model to be converted to ONNXRuntime for inference
                2. Path to ONNXRuntime saved model
  :param input_spec: A (tuple or list of) tf.TensorSpec or numpy array defining
                     the shape/dtype of the input
  :param onnxruntime_session_options: will be passed to tf2onnx.convert.from_keras function
docstr_tok: ["Create","a","ONNX","Runtime","model","from","tensorflow",".",":","param","model",":","1",".","Keras","model","to","be","converted","to","ONNXRuntime","for","inference","2",".","Path","to","ONNXRuntime","saved","model",":","param","input_spec",":","A","(","tuple","or","list","of",")","tf.TensorSpec","or","numpy","array","defining","the","shape\/dtype","of","the","input",":","param","onnxruntime_session_options",":","will","be","passed","to","tf2onnx.convert.from_keras","function"]
code: def __init__(
      self,
      model,
      input_spec=None,
      onnxruntime_session_options=None,
      **export_kwargs,
  ):
      """
      Create a ONNX Runtime model from tensorflow.
  
      :param model: 1. Keras model to be converted to ONNXRuntime for inference
                    2. Path to ONNXRuntime saved model
      :param input_spec: A (tuple or list of) tf.TensorSpec or numpy array defining
                         the shape/dtype of the input
      :param onnxruntime_session_options: will be passed to tf2onnx.convert.from_keras function
      """
      KerasOptimizedModel.__init__(self)
      with TemporaryDirectory() as tmpdir:
          if isinstance(model, tf.keras.Model):
              invalidInputError(
                  hasattr(model, "input_shape")
                  or input_spec is not None,
                  "Subclassed model must specify `input_spec` parameter.",
              )
              self._mode = "arg"
              if input_spec is None:
                  input_spec = tf.TensorSpec(
                      model.input_shape, model.dtype
                  )
              elif isinstance(input_spec, dict):
                  input_spec = [
                      tf.TensorSpec.from_spec(spec, name=name)
                      for name, spec in input_spec.items()
                  ]
                  self._mode = "kwarg"
              if isinstance(input_spec, tf.TensorSpec):
                  input_spec = (input_spec,)
  
              if self._mode == "arg":
                  self._inputs_dtypes = [
                      spec.dtype.as_numpy_dtype for spec in input_spec
                  ]
              else:
                  self._inputs_dtypes = {
                      spec.name: spec.dtype.as_numpy_dtype
                      for spec in input_spec
                  }
  
              onnx_path = os.path.join(tmpdir, "tmp.onnx")
              tf2onnx.convert.from_keras(
                  model,
                  input_signature=input_spec,
                  output_path=onnx_path,
                  **export_kwargs,
              )
  
          else:
              onnx_path = model
          ONNXRuntimeModel.__init__(
              self,
              onnx_path,
              session_options=onnxruntime_session_options,
          )
  
imports: import os
  from bigdl.nano.utils.common import SafePickle
  from pathlib import Path
  from typing import Sequence, Any, Union, Dict
  from tempfile import TemporaryDirectory
  import tensorflow
  from bigdl.nano.utils.tf import convert_all
  from bigdl.nano.tf.model import KerasOptimizedModel
  from bigdl.nano.utils.common import invalidInputError
  from ..core.onnxruntime_model import ONNXRuntimeModel
  import onnxruntime
label_desc: Use image node_id 1 to create a new KerasONNXRuntimeModel object from inherited base classes: ONNXRuntimeModel, KerasOptimizedModel with example: obj = KerasONNXRuntimeModel(model, input_spec, onnxruntime_session_options)