code: def from_torch_model(
      cls,
      model: Union[Module, GraphModule],
      network_parameters: ModelParams,
      device: Device,
      input_tfms: Optional[MultiStageTransformation] = None,
      input_data: List[torch.Tensor] = None,
  ):
      if device.type is DeviceType.GPU:
          input_data = [
              t.to(device.to_torch_format()) for t in input_data
          ]
  
      if not isinstance(model, torch.fx.GraphModule):
          model.eval()
          try:
              model_scripted = symbolic_trace(model)
              model_scripted = torch.jit.script(model_scripted)
          except Exception:
              try:
                  model_scripted = torch.jit.script(model)
              except Exception:
                  model_scripted = torch.jit.trace(
                      model, tuple(input_data)
                  )
      else:
          model_scripted = torch.jit.script(model)
  
      return cls(
          torch_model=model_scripted,
          network_parameters=network_parameters,
          input_tfms=input_tfms,
          input_data=input_data,
          device=device,
      )
  
file_path: nebuly/optimization/nebullvm/nebullvm/operations/inference_learners/torchscript.py
imports: from pathlib import Path
  from typing import Tuple, Union, Optional, List
  from nebullvm.core.models import Device, DeviceType, ModelParams
  from nebullvm.operations.inference_learners.base import PytorchBaseInferenceLearner, LearnerMetadata
  from nebullvm.optional_modules.torch import torch, symbolic_trace, Module, ScriptModule, GraphModule
  from nebullvm.tools.transformations import MultiStageTransformation
label_desc: Use image node_id 5 for calling the TorchScriptInferenceLearner obj's underlying member method code with example usage: obj.from_torch_model(cls, model, network_parameters, device, input_tfms, input_data) and returns: cls