code: def _torchscript_from_spec(
      model_spec: RecursiveScriptModule,
  ) -> RecursiveScriptModule:
      if isinstance(model_spec, str) and (
          model_spec.endswith(".pt") or model_spec.endswith(".pth")
      ):
          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 or .pth file or a TorchScript object, received: {}".format(
                  type(model_spec)
              )
          )
  
file_path: coremltools/coremltools/converters/mil/frontend/torch/load.py
imports: import os.path
  from typing import List, Optional, Union
  import torch
  from torch.jit._script import RecursiveScriptModule
  from coremltools._deps import _HAS_TORCH_EXPORT_API
  from coremltools.converters.mil.frontend.torch.converter import TorchConverter
  from coremltools.converters.mil.input_types import TensorType
  from coremltools.converters.mil.mil.program import Program
  from .converter import TorchConverter
label_desc: Use image node_id 2 for calling a global function with example usage: _torchscript_from_spec(model_spec) and returns: _torch, model_spec