class_docstr: Hook to convert a task model into torch script.
  
  Saves the torch scripts in torchscript_folder.
class_docstr_tok: ["Hook","to","convert","a","task","model","into","torch","script",".","Saves","the","torch","scripts","in","torchscript_folder","."]
docstr: The constructor method of TorchscriptHook.
  
  Args:
      torchscript_folder: Folder to store torch scripts in.
      use_trace: set to true for tracing and false for scripting,
      trace_strict: run the tracer in a strict mode or not
          (default: ``True``). Only turn this off when you want the tracer to
          record your mutable container types (currently ``list``/``dict``)
          and you are sure that the container you are using in your
          problem is a ``constant`` structure and does not get used as
          control flow (if, for) conditions.
      device: move to device before saving.
docstr_tok: ["The","constructor","method","of","TorchscriptHook",".","Args",":","torchscript_folder",":","Folder","to","store","torch","scripts","in",".","use_trace",":","set","to","true","for","tracing","and","false","for","scripting",",","trace_strict",":","run","the","tracer","in","a","strict","mode","or","not","(","default",":","``","True","``",")",".","Only","turn","this","off","when","you","want","the","tracer","to","record","your","mutable","container","types","(","currently","``","list","``","\/","``","dict","``",")","and","you","are","sure","that","the","container","you","are","using","in","your","problem","is","a","``","constant","``","structure","and","does","not","get","used","as","control","flow","(","if",",","for",")","conditions",".","device",":","move","to","device","before","saving","."]
code: def __init__(
      self,
      torchscript_folder: str,
      use_trace: bool = True,
      trace_strict: bool = True,
      device: str = "cpu",
  ) -> None:
      """The constructor method of TorchscriptHook.
  
      Args:
          torchscript_folder: Folder to store torch scripts in.
          use_trace: set to true for tracing and false for scripting,
          trace_strict: run the tracer in a strict mode or not
              (default: ``True``). Only turn this off when you want the tracer to
              record your mutable container types (currently ``list``/``dict``)
              and you are sure that the container you are using in your
              problem is a ``constant`` structure and does not get used as
              control flow (if, for) conditions.
          device: move to device before saving.
      """
      super().__init__()
      assert isinstance(
          torchscript_folder, str
      ), "torchscript_folder must be a string specifying the torchscript directory"
  
      self.torchscript_folder: str = torchscript_folder
      self.use_trace: bool = use_trace
      self.trace_strict: bool = trace_strict
      self.device: str = device
  
file_path: ClassyVision/classy_vision/hooks/torchscript_hook.py
imports: import logging
  import torch
  from classy_vision.generic.distributed_util import is_primary
  from classy_vision.generic.util import eval_model, get_model_dummy_input
  from classy_vision.hooks import register_hook
  from classy_vision.hooks.classy_hook import ClassyHook
  from fvcore.common.file_io import PathManager
label_desc: Use image node_id 1 to create a new TorchscriptHook object from inherited base classes: ClassyHook with example: obj = TorchscriptHook(torchscript_folder, use_trace, trace_strict, device)