class_docstr: Model optimized using TensorRT.
  
  The class cannot be directly instantiated, but implements all the core
  methods needed for using TensorRT at inference time.
  
  Attributes:
      network_parameters (ModelParams): The model parameters as batch
              size, input and output sizes.
      engine (any): The tensorRT engine.
      input_names (List[str]): Names associated to the model input tensors.
      output_names (List[str]): Names associated to the model output tensors.
      cuda_stream (any, optional): Stream used for communication with Nvidia
          GPUs.
      nvidia_logger (any, optional): Logger used by the Nvidia service
class_docstr_tok: ["Model","optimized","using","TensorRT",".","The","class","can","not","be","directly","instantiated",",","but","implements","all","the","core","methods","needed","for","using","TensorRT","at","inference","time",".","Attributes",":","network_parameters","(","ModelParams",")",":","The","model","parameters","as","batch","size",",","input","and","output","sizes",".","engine","(","any",")",":","The","tensorRT","engine",".","input_names","(","List","[","str","]",")",":","Names","associated","to","the","model","input","tensors",".","output_names","(","List","[","str","]",")",":","Names","associated","to","the","model","output","tensors",".","cuda_stream","(","any",",","optional",")",":","Stream","used","for","communication","with","Nvidia","GPUs",".","nvidia_logger","(","any",",","optional",")",":","Logger","used","by","the","Nvidia","service"]
docstr: Build the model from the serialised engine.
  
  Args:
      network_parameters (ModelParams): Model parameters.
      engine_path (str or Path): Path to the serialised engine. The
          serialised engine is the serialised version of the engine
          used for accelerating the inference.
      input_names (List[str]): Names associated to the model input
          tensors.
      output_names (List[str]): Names associated to the model output
          tensors.
      device: (Device): Device where the model wil be run.
      cuda_stream (any, optional): Stream used for communication with
          Nvidia GPUs.
      nvidia_logger (any, optional): Logger used by the Nvidia service
      input_tfms (MultiStageTransformation, optional): Transformations
          to be performed to the model's input tensors in order to
          get the prediction.
      input_data (DataManager, optional): User defined data.
  
  Returns:
      NvidiaInferenceLearner: The optimized model.
code: def from_engine_path(
      cls,
      network_parameters: ModelParams,
      engine_path: Union[str, Path],
      input_names: List[str],
      output_names: List[str],
      device: Device,
      nvidia_logger: Any = None,
      cuda_stream: Any = None,
      input_tfms: MultiStageTransformation = None,
      input_data: DataManager = None,
      **kwargs,
  ):
      """Build the model from the serialised engine.
  
      Args:
          network_parameters (ModelParams): Model parameters.
          engine_path (str or Path): Path to the serialised engine. The
              serialised engine is the serialised version of the engine
              used for accelerating the inference.
          input_names (List[str]): Names associated to the model input
              tensors.
          output_names (List[str]): Names associated to the model output
              tensors.
          device: (Device): Device where the model wil be run.
          cuda_stream (any, optional): Stream used for communication with
              Nvidia GPUs.
          nvidia_logger (any, optional): Logger used by the Nvidia service
          input_tfms (MultiStageTransformation, optional): Transformations
              to be performed to the model's input tensors in order to
              get the prediction.
          input_data (DataManager, optional): User defined data.
  
      Returns:
          NvidiaInferenceLearner: The optimized model.
      """
      if kwargs:
          logger.warning(
              f"Debug: Got extra keywords in "
              f"NvidiaInferenceLearner::from_engine_path: {kwargs}"
          )
      if nvidia_logger is None:
          nvidia_logger = trt.Logger(trt.Logger.WARNING)
      if input_tfms is None:
          input_tfms = MultiStageTransformation([])
      input_tfms.append(VerifyContiguity())
      runtime = trt.Runtime(nvidia_logger)
      with open(engine_path, "rb") as f:
          serialized_engine = f.read()
      engine = runtime.deserialize_cuda_engine(serialized_engine)
      return cls(
          input_tfms=input_tfms,
          network_parameters=network_parameters,
          engine=engine,
          input_names=input_names,
          output_names=output_names,
          nvidia_logger=nvidia_logger,
          cuda_stream=cuda_stream,
          input_data=input_data,
          device=device,
      )
  
imports: import json
  import os
  from abc import ABC
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Any, Union, Dict, Type, List, Tuple, Generator, Optional
  import numpy
  from loguru import logger
  from nebullvm.config import NVIDIA_FILENAMES
  from nebullvm.core.models import Device, DeviceType, ModelParams, DeepLearningFramework
  from nebullvm.operations.inference_learners.base import BaseInferenceLearner, LearnerMetadata, PytorchBaseInferenceLearner, TensorflowBaseInferenceLearner, NumpyBaseInferenceLearner
  from nebullvm.optional_modules.tensorflow import tensorflow
  from nebullvm.optional_modules.tensor_rt import tensorrt, polygraphy
  from nebullvm.optional_modules.torch import torch, ScriptModule
  from nebullvm.tools.data import DataManager
  from nebullvm.tools.transformations import MultiStageTransformation, VerifyContiguity
label_desc: Use image node_id 8 for calling the ONNXTensorRTInferenceLearner obj's underlying member method code with example usage: obj.from_engine_path(cls, network_parameters, engine_path, input_names, output_names, device, nvidia_logger, cuda_stream, input_tfms, input_data) and returns: cls