code: def load_model_text(
      file: str,  # File name of saved text model
      model,  # Model architecture
      opt: Optimizer,  # `Optimizer` used to fit the model
      with_opt: bool = None,  # Enable to load `Optimizer` state
      device: int
      | str
      | torch.device = None,  # Sets the device, uses 'cpu' if unspecified
      strict: bool = True,  # Whether to strictly enforce the keys of `file`s state dict match with the model `Module.state_dict`
  ):
      "Load `model` from `file` along with `opt` (if available, and if `with_opt`)"
      distrib_barrier()
      if isinstance(device, int):
          device = torch.device("cuda", device)
      elif device is None:
          device = "cpu"
      state = torch.load(file, map_location=device)
      hasopt = set(state) == {"model", "opt"}
      model_state = state["model"] if hasopt else state
      get_model(model).load_state_dict(
          clean_raw_keys(model_state), strict=strict
      )
      if hasopt and ifnone(with_opt, True):
          try:
              opt.load_state_dict(state["opt"])
          except:
              if with_opt:
                  warn("Could not load the optimizer state.")
      elif with_opt:
          warn("Saved file doesn't contain an optimizer state.")
  
imports: from __future__ import annotations
  from ..basics import *
  from .core import *
  from .data import *
  from .models.core import *
  from .models.awdlstm import *
  from ..callback.rnn import *
  from ..callback.progress import *
  from .models.core import _model_meta
label_desc: Use image node_id 6 for calling a global function with example usage: load_model_text(file, model, opt, with_opt, device, strict) without return types