class_docstr: a `Predictor` is a thin wrapper around an AllenNLP model that handles JSON -> JSON predictions
  that can be used for serving models through the web API or making predictions in bulk.
docstr: Instantiate a `Predictor` from an [`Archive`](../models/archival.md);
  that is, from the result of training a model. Optionally specify which `Predictor`
  subclass; otherwise, we try to find a corresponding predictor in `DEFAULT_PREDICTORS`, or if
  one is not found, the base class (i.e. `Predictor`) will be used. Optionally specify
  which [`DatasetReader`](../data/dataset_readers/dataset_reader.md) should be loaded;
  otherwise, the validation one will be used if it exists followed by the training dataset reader.
  Optionally specify if the loaded model should be frozen, meaning `model.eval()` will be called.
docstr_tok: ["Instantiate","a","`","Predictor","`","from","an","[","`","Archive","`","]","(","..","\/models\/archival.md",")",";","that","is",",","from","the","result","of","training","a","model",".","Optionally","specify","which","`","Predictor","`","subclass",";","otherwise",",","we","try","to","find","a","corresponding","predictor","in","`","DEFAULT_PREDICTORS","`",",","or","if","one","is","not","found",",","the","base","class","(","i.e",".","`","Predictor","`",")","will","be","used",".","Optionally","specify","which","[","`","DatasetReader","`","]","(","..","\/data\/dataset_readers\/dataset_reader.md",")","should","be","loaded",";","otherwise",",","the","validation","one","will","be","used","if","it","exists","followed","by","the","training","dataset","reader",".","Optionally","specify","if","the","loaded","model","should","be","frozen",",","meaning","`","model.eval","(",")","`","will","be","called","."]
code: def from_archive(
      cls,
      archive: Archive,
      predictor_name: str = None,
      dataset_reader_to_load: str = "validation",
      frozen: bool = True,
      extra_args: Optional[Dict[str, Any]] = None,
  ) -> "Predictor":
      """
      Instantiate a `Predictor` from an [`Archive`](../models/archival.md);
      that is, from the result of training a model. Optionally specify which `Predictor`
      subclass; otherwise, we try to find a corresponding predictor in `DEFAULT_PREDICTORS`, or if
      one is not found, the base class (i.e. `Predictor`) will be used. Optionally specify
      which [`DatasetReader`](../data/dataset_readers/dataset_reader.md) should be loaded;
      otherwise, the validation one will be used if it exists followed by the training dataset reader.
      Optionally specify if the loaded model should be frozen, meaning `model.eval()` will be called.
      """
      # Duplicate the config so that the config inside the archive doesn't get consumed
      config = archive.config.duplicate()
  
      if not predictor_name:
          model_type = config.get("model").get("type")
          model_class, _ = Model.resolve_class_name(model_type)
          predictor_name = model_class.default_predictor
      predictor_class: Type[Predictor] = (
          Predictor.by_name(predictor_name) if predictor_name is not None else cls  # type: ignore
      )
  
      if dataset_reader_to_load == "validation":
          dataset_reader = archive.validation_dataset_reader
      else:
          dataset_reader = archive.dataset_reader
  
      model = archive.model
      if frozen:
          model.eval()
  
      if extra_args is None:
          extra_args = {}
  
      return predictor_class(model, dataset_reader, **extra_args)
  
imports: from typing import List, Iterator, Dict, Tuple, Any, Type, Union, Optional
  import logging
  from os import PathLike
  import json
  import re
  from contextlib import contextmanager
  import numpy
  import torch
  from torch.utils.hooks import RemovableHandle
  from torch import Tensor
  from torch import backends
  from allennlp.common import Registrable, plugins
  from allennlp.common.util import JsonDict, sanitize
  from allennlp.data import DatasetReader, Instance
  from allennlp.data.batch import Batch
  from allennlp.models import Model
  from allennlp.models.archival import Archive, load_archive
  from allennlp.nn import util
label_desc: Use image node_id 18 for calling the Predictor obj's underlying member method code with example usage: obj.from_archive(cls, archive, predictor_name, dataset_reader_to_load, frozen, extra_args) and returns: predictor_class