code: def _compile_model(
      self,
      model: Union[Module, GraphModule],
      input_data: DataManager,
      quantization_type: QuantizationType,
  ) -> ScriptModule:
      input_sample = input_data.get_list(1)[0]
      if self.device.type is DeviceType.GPU:
          if quantization_type is QuantizationType.HALF:
              input_sample = [
                  t.to(self.device.to_torch_format()).half()
                  if torch.is_floating_point(t)
                  else t.to(self.device.to_torch_format())
                  for t in input_sample
              ]
          else:
              input_sample = [
                  t.to(self.device.to_torch_format())
                  for t in input_sample
              ]
          model.to(self.device.to_torch_format())
  
      if not isinstance(model, torch.fx.GraphModule):
          model.eval()
          try:
              model_scripted = symbolic_trace(model)
              model_scripted = torch.jit.script(model_scripted)
          except Exception:
              if quantization_type is None:
                  self.logger.warning(
                      "Unable to trace model with torch.fx"
                  )
              try:
                  model_scripted = torch.jit.script(model)
              except Exception:
                  model_scripted = torch.jit.trace(model, input_sample)
      else:
          model_scripted = torch.jit.script(model)
  
      return model_scripted
  
file_path: nebuly/optimization/nebullvm/nebullvm/operations/optimizations/compilers/torchscript.py
imports: from typing import Union, List, Tuple
  from nebullvm.config import QUANTIZATION_DATA_NUM
  from nebullvm.core.models import QuantizationType, DeviceType
  from nebullvm.operations.optimizations.compilers.base import Compiler
  from nebullvm.operations.optimizations.compilers.quantizations.pytorch import quantize_pytorch
  from nebullvm.operations.optimizations.compilers.quantizations.utils import check_quantization
  from nebullvm.optional_modules.torch import torch, Module, ScriptModule, GraphModule, symbolic_trace
  from nebullvm.tools.data import DataManager
  from nebullvm.tools.transformations import MultiStageTransformation
label_desc: Use image node_id 2 for calling the TorchScriptCompiler obj's underlying member method code with example usage: obj._compile_model(model, input_data, quantization_type) and returns: model_scripted