class_docstr: This abstract class represents a model to be trained. Rather than relying completely
  on the Pytorch Module, we modify the output spec of ``forward`` to be a dictionary.
  
  Models built using this API are still compatible with other pytorch models and can
  be used naturally as modules within other models - outputs are dictionaries, which
  can be unpacked and passed into other layers. One caveat to this is that if you
  wish to use an AllenNLP model inside a Container (such as nn.Sequential), you must
  interleave the models with a wrapper module which unpacks the dictionary into
  a list of tensors.
  
  In order for your model to be trained using the :class:`~allennlp.training.Trainer`
  api, the output dictionary of your Model must include a "loss" key, which will be
  optimised during the training process.
  
  Finally, you can optionally implement :func:`Model.get_metrics` in order to make use
  of early stopping and best-model serialization based on a validation metric in
  :class:`~allennlp.training.Trainer`. Metrics that begin with "_" will not be logged
  to the progress bar by :class:`~allennlp.training.Trainer`.
docstr: Instantiates an already-trained model, based on the experiment
  configuration and some optional overrides.
docstr_tok: ["Instantiates","an","already-trained","model",",","based","on","the","experiment","configuration","and","some","optional","overrides","."]
code: def _load(
      cls, config, serialization_dir, weights_file=None, cuda_device=-1
  ):
      """
      Instantiates an already-trained model, based on the experiment
      configuration and some optional overrides.
      """
      weights_file = weights_file or os.path.join(
          serialization_dir, _DEFAULT_WEIGHTS
      )
  
      # Load vocabulary from file
      vocab_dir = os.path.join(serialization_dir, "vocabulary")
      vocab = Vocabulary.from_files(vocab_dir)
  
      model_params = config.get("model")
  
      # The experiment config tells us how to _train_ a model, including where to get pre-trained
      # embeddings from.  We're now _loading_ the model, so those embeddings will already be
      # stored in our weights.  We don't need any pretrained weight file anymore, and we don't
      # want the code to look for it, so we remove it from the parameters here.
      remove_pretrained_embedding_params(model_params)
      model = Model.from_params(vocab=vocab, params=model_params)
      model_state = torch.load(
          weights_file, map_location=util.device_mapping(cuda_device)
      )
      model.load_state_dict(model_state)
  
      # Force model to cpu or gpu, as appropriate, to make sure that the embeddings are
      # in sync with the weights
      if cuda_device >= 0:
          model.cuda(cuda_device)
      else:
          model.cpu()
  
      return model
  
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import logging
  import os
  import numpy
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.params import Params
  from allennlp.common.registrable import Registrable
  from allennlp.data import Instance, Vocabulary
  from allennlp.data.dataset import Batch
  from allennlp.nn import util
  from allennlp.nn.regularizers import RegularizerApplicator
label_desc: Use image node_id 11 for calling the Model obj's underlying member method code with example usage: obj._load(cls, config, serialization_dir, weights_file, cuda_device) and returns: model