class_docstr: A helper class to enable `ORTModel` instances to prepare IO binding  with dynamic shaped outputs for an inference session and transfer
  tensors from ONNX Runtime to other frameworks on device. It helps reduce memory copy between the host and device.
class_docstr_tok: ["A","helper","class","to","enable","`","ORTModel","`","instances","to","prepare","IO","binding","with","dynamic","shaped","outputs","for","an","inference","session","and","transfer","tensors","from","ONNX","Runtime","to","other","frameworks","on","device",".","It","helps","reduce","memory","copy","between","the","host","and","device","."]
docstr: Returns an IOBinding object for an inference session. This method is for general purpose, if the inputs and outputs
  are determined, you can prepare data buffers directly to avoid tensor transfers across frameworks.
docstr_tok: ["Returns","an","IOBinding","object","for","an","inference","session",".","This","method","is","for","general","purpose",",","if","the","inputs","and","outputs","are","determined",",","you","can","prepare","data","buffers","directly","to","avoid","tensor","transfers","across","frameworks","."]
code: def prepare_io_binding(
      ort_model: "ORTModel", **inputs
  ) -> ort.IOBinding:
      """
      Returns an IOBinding object for an inference session. This method is for general purpose, if the inputs and outputs
      are determined, you can prepare data buffers directly to avoid tensor transfers across frameworks.
      """
      if not all(
          input_name in inputs.keys()
          for input_name in ort_model.inputs_names
      ):
          raise ValueError(
              f"The ONNX model takes {ort_model.inputs_names.keys()} as inputs, but only {inputs.keys()} are given."
          )
  
      name_to_np_type = TypeHelper.get_io_numpy_type_map(
          ort_model.model
      )
  
      # Bind inputs and outputs to onnxruntime session
      io_binding = ort_model.model.io_binding()
  
      # Bind inputs
      for input_name in ort_model.inputs_names:
          onnx_input = inputs.pop(input_name)
          onnx_input = onnx_input.contiguous()
  
          io_binding.bind_input(
              input_name,
              onnx_input.device.type,
              ort_model.device.index,
              name_to_np_type[input_name],
              list(onnx_input.size()),
              onnx_input.data_ptr(),
          )
  
      # Bind outputs
      for name in ort_model.output_names:
          io_binding.bind_output(
              name,
              ort_model.device.type,
              device_id=ort_model.device.index,
          )
  
      return io_binding
  
imports: import logging
  import traceback
  from typing import TYPE_CHECKING
  import numpy
  import torch
  import onnxruntime
  from onnxruntime.capi.onnxruntime_inference_collection import OrtValue
  from onnxruntime.transformers.io_binding_helper import TypeHelper
  from ..utils import is_cupy_available, is_onnxruntime_training_available
label_desc: Use image node_id 7 for calling the IOBindingHelper obj's underlying member method code with example usage: obj.prepare_io_binding(ort_model) and returns: io_binding