docstr: Compile the input model using TensorRT Compiler from the
      PyTorch interface.
  
  Args:
      model (torch.nn.Module): The pytorch model.
      model_params (ModelParams): The model parameters.
      input_tfms (MultiStageTransformation, optional): Transformations
          to be performed to the model's input tensors in order to
          get the prediction. Default: None.
      metric_drop_ths (float, optional): Threshold for the accepted drop
          in terms of precision. Any optimized model with a higher drop
          will be ignored. Default: None.
      quantization_type (QuantizationType, optional): The desired
          quantization algorithm to be used. Default: None.
      input_data (DataManager): User defined data. Default: None
docstr_tok: ["Compile","the","input","model","using","TensorRT","Compiler","from","the","PyTorch","interface",".","Args",":","model","(","torch.nn.Module",")",":","The","pytorch","model",".","model_params","(","ModelParams",")",":","The","model","parameters",".","input_tfms","(","MultiStageTransformation",",","optional",")",":","Transformations","to","be","performed","to","the","model","'s","input","tensors","in","order","to","get","the","prediction",".","Default",":","None",".","metric_drop_ths","(","float",",","optional",")",":","Threshold","for","the","accepted","drop","in","terms","of","precision",".","Any","optimized","model","with","a","higher","drop","will","be","ignored",".","Default",":","None",".","quantization_type","(","QuantizationType",",","optional",")",":","The","desired","quantization","algorithm","to","be","used",".","Default",":","None",".","input_data","(","DataManager",")",":","User","defined","data",".","Default",":","None"]
code: def execute(
      self,
      model: Module,
      model_params: ModelParams,
      input_tfms: MultiStageTransformation = None,
      metric_drop_ths: float = None,
      quantization_type: QuantizationType = None,
      input_data: DataManager = None,
      **kwargs,
  ):
      """Compile the input model using TensorRT Compiler from the
          PyTorch interface.
  
      Args:
          model (torch.nn.Module): The pytorch model.
          model_params (ModelParams): The model parameters.
          input_tfms (MultiStageTransformation, optional): Transformations
              to be performed to the model's input tensors in order to
              get the prediction. Default: None.
          metric_drop_ths (float, optional): Threshold for the accepted drop
              in terms of precision. Any optimized model with a higher drop
              will be ignored. Default: None.
          quantization_type (QuantizationType, optional): The desired
              quantization algorithm to be used. Default: None.
          input_data (DataManager): User defined data. Default: None
      """
  
      if (
          quantization_type
          not in self.supported_ops[self.device.type.value]
      ):
          self.compiled_model = None
          return
  
      if (
          quantization_type is QuantizationType.STATIC
          and input_data is None
      ):
          raise ValueError(
              "Input data is required for static quantization."
          )
  
      self.logger.info(
          f"Optimizing with {self.__class__.__name__} and "
          f"q_type: {quantization_type}."
      )
  
      check_quantization(quantization_type, metric_drop_ths)
  
      if quantization_type is QuantizationType.HALF:
          dtype = torch.half
          input_tfms.append(HalfPrecisionTransformation())
      elif quantization_type is QuantizationType.STATIC:
          if model_params.dynamic_info is not None:
              self.logger.warning(
                  "Static quantization is not available when "
                  "using dynamic shape"
              )
              return
          dtype = torch.int8
  
          dataset = PytorchDataset(input_data.get_split("train"))
          dataloader = torch.utils.data.DataLoader(
              dataset,
              batch_size=dataset.batch_size,
              shuffle=False,
              num_workers=0,
          )
  
          calibrator = torch_tensorrt.ptq.DataLoaderCalibrator(
              dataloader,
              use_cache=False,
              algo_type=torch_tensorrt.ptq.CalibrationAlgo.ENTROPY_CALIBRATION_2,  # noqa E501
              device=torch.device(self.device.to_torch_format()),
          )
      else:
          dtype = torch.float32
  
      # Convert int64 to int32 for transformers inputs
      input_tensors = [
          tensor.to(self.device.to_torch_format())
          if tensor.dtype != torch.int64
          else tensor.to(torch.int32).to(self.device.to_torch_format())
          for tensor in input_data.get_list(1)[0]
      ]
  
      self.compiled_model = self._compile_model(
          model=model,
          model_params=model_params,
          input_tensors=input_tensors,
          dtype=dtype,
          calibrator=calibrator
          if quantization_type is QuantizationType.STATIC
          else None,  # noqa E501
          quantization_type=quantization_type,
      )
  
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 1 for calling the PyTorchTensorRTCompiler obj's underlying member method code with example usage: obj.execute(model, model_params, input_tfms, metric_drop_ths, quantization_type, input_data) without return types