code: def __init__(
      self,
      *,
      onnx: Optional[ONNX] = None,
      model: Optional[IDLModel] = None,
      use_grad_in_predict: bool = False,
  ):
      self.onnx = onnx
      self.model = model
      if onnx is None and model is None:
          raise ValueError(
              "either `onnx` or `model` should be provided"
          )
      if onnx is not None and model is not None:
          raise ValueError(
              "only one of `onnx` & `model` should be provided"
          )
      self.use_grad_in_predict = use_grad_in_predict
  
imports: import numpy
  from tqdm import tqdm
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Union
  from typing import Optional
  from cftool.misc import filter_kw
  from cftool.misc import shallow_copy_dict
  from cftool.array import to_numpy
  from cftool.array import to_device
  from cftool.types import np_dict_type
  from .schema import ILoss
  from .schema import IMetric
  from .schema import IDLModel
  from .schema import IInference
  from .schema import IDataLoader
  from .schema import TrainerState
  from .schema import MetricsOutputs
  from .schema import InferenceOutputs
  from .constants import INPUT_KEY
  from .constants import LABEL_KEY
  from .constants import BATCH_INDICES_KEY
  from .constants import ORIGINAL_LABEL_KEY
  from .misc.toolkit import eval_context
  from .misc.toolkit import get_device
  from .misc.toolkit import np_batch_to_tensor
  from .misc.toolkit import ONNX
label_desc: Use image node_id 1 to create a new DLInference object from inherited base classes: IInference with example: obj = DLInference()