class_docstr: A Thinc shim that wraps a TorchScript module.
  
  model:
      The TorchScript module. A value of `None` is also possible to
      construct a shim to deserialize into.
  mixed_precision:
      Enable mixed-precision. This changes whitelisted ops to run
      in half precision for better performance and lower memory use.
  grad_scaler:
      The gradient scaler to use for mixed-precision training. If this
      argument is set to "None" and mixed precision is enabled, a gradient
      scaler with the default configuration is used.
  device:
      The PyTorch device to run the model on. When this argument is
      set to "None", the default device for the currently active Thinc
      ops is used.
code: def __init__(
      self,
      model: Optional["torch.ScriptModule"],
      config=None,
      optimizer: Any = None,
      mixed_precision: bool = False,
      grad_scaler: Optional[PyTorchGradScaler] = None,
      device: Optional["torch.device"] = None,
  ):
      if model is not None and not isinstance(
          model, torch.jit.ScriptModule
      ):
          raise ValueError(
              "PyTorchScriptShim must be initialized with ScriptModule or None (for deserialization)"
          )
  
      super().__init__(
          model, config, optimizer, mixed_precision, grad_scaler, device
      )
  
file_path: thinc/thinc/shims/torchscript.py
imports: from io import BytesIO
  from typing import Any, Optional
  import srsly
  from ..compat import torch
  from ..util import get_torch_default_device
  from .pytorch import PyTorchShim
  from .pytorch_grad_scaler import PyTorchGradScaler
label_desc: Use image node_id 1 to create a new TorchScriptShim object from inherited base classes: PyTorchShim with example: obj = TorchScriptShim(model, config, optimizer, mixed_precision, grad_scaler, device)