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 from_bytes(self, bytes_data):
      device = get_torch_default_device()
      msg = srsly.msgpack_loads(bytes_data)
      self.cfg = msg["config"]
      filelike = BytesIO(msg["model"])
      filelike.seek(0)
      # As of Torch 2.0.0, loading TorchScript models directly to
      # an MPS device is not supported.
      map_location = (
          torch.device("cpu") if device.type == "mps" else device
      )
      self._model = torch.jit.load(filelike, map_location=map_location)
      self._model.to(device)
      self._grad_scaler.to_(device)
      return self
  
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 3 for calling the TorchScriptShim obj's underlying member method code with example usage: obj.from_bytes(bytes_data) and returns: self