code: def _torchscript_from_model(model_spec):
      if isinstance(model_spec, _string_types) and model_spec.endswith(
          ".pt"
      ):
          filename = _os_path.abspath(model_spec)
          return _torch.jit.load(filename)
      elif isinstance(model_spec, _torch.jit.ScriptModule):
          return model_spec
      else:
          raise TypeError(
              "@model must either be a PyTorch .pt file or a TorchScript object, received: {}".format(
                  type(model_spec)
              )
          )
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/torch/load.py
imports: from __future__ import print_function
  import logging
  import os.path
  import torch
  from six import string_types
  from .converter import TorchConverter, torch_to_mil_types
  from coremltools.converters.mil.input_types import InputType, TensorType
  from coremltools.converters.mil.mil import Program, types
label_desc: Use image node_id 2 for calling a global function with example usage: _torchscript_from_model(model_spec) and returns: _torch, model_spec