code: def _compile_model(
      self,
      model: Module,
      model_params: ModelParams,
      input_tensors: List[torch.Tensor],
      dtype: torch.dtype,
      calibrator: DataLoaderCalibrator,
      quantization_type: QuantizationType,
  ):
      model.to(self.device.to_torch_format()).eval()
  
      try:
          if quantization_type is QuantizationType.HALF:
              ts_model = torch.jit.script(
                  copy.deepcopy(model).half()
              ).half()
          else:
              ts_model = torch.jit.script(model)
      except Exception:
          if quantization_type is QuantizationType.HALF:
              ts_model = torch.jit.trace(
                  copy.deepcopy(model).half(),
                  [t.half() for t in input_tensors],
              ).half()
          else:
              ts_model = torch.jit.trace(model, input_tensors)
  
      with torch_tensorrt.logging.errors():
          inputs_shapes = self._extract_dynamic_shape_ranges(
              model_params
          )
          trt_model = torch_tensorrt.compile(
              ts_model,
              inputs=[
                  torch_tensorrt.Input(
                      **inputs_shapes[i],
                      dtype=torch.half
                      if (
                          dtype == torch.half
                          and tensor.dtype
                          not in [torch.int8, torch.int32]
                      )
                      else tensor.dtype,
                  )
                  for i, tensor in enumerate(input_tensors)
              ],
              enabled_precisions=TORCH_TENSORRT_PRECISIONS[str(dtype)],
              calibrator=calibrator
              if quantization_type is QuantizationType.STATIC
              else None,
              workspace_size=self.device.get_free_memory(),
              device={
                  "device_type": torch_tensorrt.DeviceType.GPU,
                  "gpu_id": self.device.idx,
                  "dla_core": 0,
                  "allow_gpu_fallback": False,
                  "disable_tf32": False,
              },
              truncate_long_and_double=True,
          )
  
      # Delete calibration cache
      if os.path.exists("calibration.cache"):
          os.remove("calibration.cache")
  
      return trt_model
  
imports: import abc
  import copy
  import os
  import subprocess
  from pathlib import Path
  from typing import List, Any, Tuple
  import numpy
  from nebullvm.config import QUANTIZATION_DATA_NUM, TORCH_TENSORRT_PRECISIONS
  from nebullvm.core.models import QuantizationType, ModelParams
  from nebullvm.operations.optimizations.compilers.base import Compiler
  from nebullvm.operations.optimizations.compilers.quantizations.tensor_rt import quantize_tensorrt
  from nebullvm.operations.optimizations.compilers.quantizations.utils import check_quantization
  from nebullvm.optional_modules.onnx import onnx
  from nebullvm.optional_modules.tensor_rt import tensorrt
  from nebullvm.optional_modules.torch import torch, Module
  from nebullvm.optional_modules.torch_tensorrt import torch_tensorrt, DataLoaderCalibrator
  from nebullvm.tools.data import DataManager, PytorchDataset
  from nebullvm.tools.diffusers import UNet
  from nebullvm.tools.onnx import get_input_names
  from nebullvm.tools.transformations import MultiStageTransformation, HalfPrecisionTransformation
label_desc: Use image node_id 2 for calling the PyTorchTensorRTCompiler obj's underlying member method code with example usage: obj._compile_model(model, model_params, input_tensors, dtype, calibrator, quantization_type) and returns: trt_model