class_docstr: Experimental
docstr: We are using torchscript to save the model
docstr_tok: ["We","are","using","torchscript","to","save","the","model"]
code: def save_model(self) -> None:
      """We are using torchscript to save the model"""
      logging.info("Saving pytorch model...")
      path = Path(f"{self.model_path}.{self.model_format}")
  
      logger.info("Checking torch import...")
      if "torch" not in sys.modules:
          try:
              import torch
          except ImportError:
              logger.error(
                  "Torch import not found, please install torch to use torchscript"
              )
              raise ImportError(
                  "Torch import not found, please install torch to use torchscript"
              )
      else:
          import torch
  
          logger.info(
              "Torch import found, using torchscript to save the model..."
          )
  
      if self.model:
          self.model_format = "pt"
          path = Path(f"{self.model_path}.{self.model_format}")
  
          traced_model = torch.jit.trace(
              self.model, self.schema.get_input_sample()
          )
          torch.jit.save(traced_model, path.resolve().as_posix())
  
      self.schema_path, self.schema_format = capture_schema(
          self.schema_path, self.schema_format, self.schema
      )
      if self.inference_spec:
          path = Path(
              f"{self.inference_spec_path}.{self.inference_spec_format}"
          )
          save_pkl(path, self.inference_spec)
  
      self._pytorch_generate_hmac()
      logging.info("Pytorch model saved successfully")
  
imports: from __future__ import absolute_import
  import platform
  import logging
  import sys
  from pathlib import Path
  from typing import Type
  from sagemaker.serve.save_retrive.version_1_0_0.save.utils import generate_secret_key, compute_hash, save_pkl, save_yaml, capture_schema, get_image_url
  from sagemaker import Session
  from sagemaker.predictor import Predictor
  from sagemaker.serve.save_retrive.version_1_0_0.metadata.metadata import PyTorchMetadata
  from sagemaker.model import Model
  from sagemaker.serve.save_retrive.version_1_0_0.save.framework.framework_handler import FrameworkHandler
  from sagemaker.serve.builder.schema_builder import SchemaBuilder
  from sagemaker.serve.spec.inference_spec import InferenceSpec
label_desc: Use image node_id 3 for calling the PyTorchHandler obj's underlying member method code with example usage: obj.save_model() without return types