class_docstr: Same as :class:`Checkpointer`, but is able to:
  1. handle models in detectron & detectron2 model zoo, and apply conversions for legacy models.
  2. correctly load checkpoints that are only available on the master worker
class_docstr_tok: ["Same","as",":","class",":","`","Checkpointer","`",",","but","is","able","to",":","1.","handle","models","in","detectron","&","detectron2","model","zoo",",","and","apply","conversions","for","legacy","models",".","2.","correctly","load","checkpoints","that","are","only","available","on","the","master","worker"]
code: def _load_file(self, filename):
      if filename.endswith(".pkl"):
          with PathManager.open(filename, "rb") as f:
              data = pickle.load(f, encoding="latin1")
          if "model" in data and "__author__" in data:
              # file is in Detectron2 model zoo format
              self.logger.info(
                  "Reading a file from '{}'".format(data["__author__"])
              )
              return data
          else:
              # assume file is from Caffe2 / Detectron1 model zoo
              if "blobs" in data:
                  # Detection models have "blobs", but ImageNet models don't
                  data = data["blobs"]
              data = {
                  k: v
                  for k, v in data.items()
                  if not k.endswith("_momentum")
              }
              return {
                  "model": data,
                  "__author__": "Caffe2",
                  "matching_heuristics": True,
              }
      elif filename.endswith(".pyth"):
          # assume file is from pycls; no one else seems to use the ".pyth" extension
          with PathManager.open(filename, "rb") as f:
              data = torch.load(f)
          assert (
              "model_state" in data
          ), f"Cannot load .pyth file {filename}; pycls checkpoints must contain 'model_state'."
          model_state = {
              k: v
              for k, v in data["model_state"].items()
              if not k.endswith("num_batches_tracked")
          }
          return {
              "model": model_state,
              "__author__": "pycls",
              "matching_heuristics": True,
          }
  
      loaded = self._torch_load(filename)
      if "model" not in loaded:
          loaded = {"model": loaded}
      assert (
          self._parsed_url_during_load is not None
      ), "`_load_file` must be called inside `load`"
      parsed_url = self._parsed_url_during_load
      queries = parse_qs(parsed_url.query)
      if queries.pop("matching_heuristics", "False") == ["True"]:
          loaded["matching_heuristics"] = True
      if len(queries) > 0:
          raise ValueError(
              f"Unsupported query remaining: f{queries}, orginal filename: {parsed_url.geturl()}"
          )
      return loaded
  
file_path: detectron2/detectron2/checkpoint/detection_checkpoint.py
imports: import logging
  import os
  import pickle
  from urllib.parse import parse_qs, urlparse
  import torch
  from fvcore.common.checkpoint import Checkpointer
  from torch.nn.parallel import DistributedDataParallel
  import detectron2.utils.comm
  from detectron2.utils.file_io import PathManager
  from .c2_model_loading import align_and_update_state_dicts
label_desc: Use image node_id 3 for calling the DetectionCheckpointer obj's underlying member method code with example usage: obj._load_file(filename) and returns: loaded, data, dict, dict