class_docstr: Script to convert a transformer-based fairseq model to ParlAI Model.
class_docstr_tok: ["Script","to","convert","a","transformer-based","fairseq","model","to","ParlAI","Model","."]
docstr: Loads a fairseq model from file.
  
  :param path:
      path to file
  
  :return state:
      loaded fairseq state
docstr_tok: ["Loads","a","fairseq","model","from","file",".",":","param","path",":","path","to","file",":","return","state",":","loaded","fairseq","state"]
code: def _load_single_fairseq_checkpoint(
      self, path: str
  ) -> Dict[str, Any]:
      """
      Loads a fairseq model from file.
  
      :param path:
          path to file
  
      :return state:
          loaded fairseq state
      """
      with PathManager.open(path, "rb") as f:
          try:
              state = torch.load(
                  f,
                  map_location=lambda s, l: default_restore_location(
                      s, "cpu"
                  ),
              )
          except ModuleNotFoundError:
              raise RuntimeError(
                  "Please install fairseq: https://github.com/pytorch/fairseq#requirements-and-installation"
              )
  
      return state
  
imports: from collections import OrderedDict
  import os
  import torch
  from torch.serialization import default_restore_location
  from typing import Any, Dict, List
  from parlai.core.agents import create_agent
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.script import ParlaiScript
  from parlai.utils.io import PathManager
  from parlai.scripts.vacuum import Vacuum
label_desc: Use image node_id 5 for calling the ConversionScript obj's underlying member method code with example usage: obj._load_single_fairseq_checkpoint(path) and returns: state