class_docstr: An `InfluenceInterpreter` interprets an AllenNLP models's outputs by finding the
  training instances that had the most influence on the prediction for each test input.
  
  See [Understanding Black-box Predictions via Influence Functions]
  (https://api.semanticscholar.org/CorpusID:13193974) for more information.
  
  Subclasses are required to implement the `_calculate_influence_scores()` method.
  
  # Parameters
  
  model : `Model`, required
  
  train_data_path : `DatasetReaderInput`, required
  
  train_dataset_reader : `DatasetReader`, required
  
  test_dataset_reader : `Optional[DatasetReader]`, optional (default = `None`)
      This is the dataset reader to read the test set file. If not provided, the
      `train_dataset_reader` is used.
  
  train_data_loader : `Lazy[DataLoader]`, optional (default = `Lazy(SimpleDataLoader)`)
      The data loader used to load training instances.
  
      !!! Note
          This data loader is only used to call `DataLoader.iter_instances()`, so certain
          `DataLoader` settings like `batch_size` will have no effect.
  
  test_data_loader : `Lazy[DataLoader]`, optional (default = `Lazy(SimpleDataLoader)`)
      The data loader used to load test instances when `interpret_from_file()` is called.
  
      !!! Note
          Like `train_data_loader`, this data loader is only used to call `DataLoader.iter_instances()`,
          so certain `DataLoader` settings like `batch_size` will have no effect.
  
  params_to_freeze : `Optional[List[str]]`, optional (default = `None`)
      An optional list of strings, each of which should be a regular expression that matches
      some parameter keys of the model. Any matching parameters will be have `requires_grad`
      set to `False`.
  
  cuda_device : `int`, optional (default = `-1`)
      The index of GPU device we want to calculate scores on. If not provided, we uses `-1`
      which correspond to using CPU.
class_docstr_tok: ["An","`","InfluenceInterpreter","`","interprets","an","AllenNLP","models","'s","outputs","by","finding","the","training","instances","that","had","the","most","influence","on","the","prediction","for","each","test","input",".","See","[","Understanding","Black-box","Predictions","via","Influence","Functions","]","(","https",":","\/\/api.semanticscholar.org\/CorpusID:13193974",")","for","more","information",".","Subclasses","are","required","to","implement","the","`","_calculate_influence_scores","(",")","`","method",".","#","Parameters","model",":","`","Model","`",",","required","train_data_path",":","`","DatasetReaderInput","`",",","required","train_dataset_reader",":","`","DatasetReader","`",",","required","test_dataset_reader",":","`","Optional","[","DatasetReader","]","`",",","optional","(","default","=","`","None","`",")","This","is","the","dataset","reader","to","read","the","test","set","file",".","If","not","provided",",","the","`","train_dataset_reader","`","is","used",".","train_data_loader",":","`","Lazy","[","DataLoader","]","`",",","optional","(","default","=","`","Lazy","(","SimpleDataLoader",")","`",")","The","data","loader","used","to","load","training","instances",".","!","!","!","Note","This","data","loader","is","only","used","to","call","`","DataLoader.iter_instances","(",")","`",",","so","certain","`","DataLoader","`","settings","like","`","batch_size","`","will","have","no","effect",".","test_data_loader",":","`","Lazy","[","DataLoader","]","`",",","optional","(","default","=","`","Lazy","(","SimpleDataLoader",")","`",")","The","data","loader","used","to","load","test","instances","when","`","interpret_from_file","(",")","`","is","called",".","!","!","!","Note","Like","`","train_data_loader","`",",","this","data","loader","is","only","used","to","call","`","DataLoader.iter_instances","(",")","`",",","so","certain","`","DataLoader","`","settings","like","`","batch_size","`","will","have","no","effect",".","params_to_freeze",":","`","Optional","[","List","[","str","]","]","`",",","optional","(","default","=","`","None","`",")","An","optional","list","of","strings",",","each","of","which","should","be","a","regular","expression","that","matches","some","parameter","keys","of","the","model",".","Any","matching","parameters","will","be","have","`","requires_grad","`","set","to","`","False","`",".","cuda_device",":","`","int","`",",","optional","(","default","=","`","-1","`",")","The","index","of","GPU","device","we","want","to","calculate","scores","on",".","If","not","provided",",","we","uses","`","-1","`","which","correspond","to","using","CPU","."]
docstr: Run the influence function scorer on the given instance, returning the top `k`
  most influential train instances with their scores.
  
  !!! Note
      Test instances should have `targets` so that a loss can be computed.
docstr_tok: ["Run","the","influence","function","scorer","on","the","given","instance",",","returning","the","top","`","k","`","most","influential","train","instances","with","their","scores",".","!","!","!","Note","Test","instances","should","have","`","targets","`","so","that","a","loss","can","be","computed","."]
code: def interpret(
      self, test_instance: Instance, k: int = 20
  ) -> InterpretOutput:
      """
      Run the influence function scorer on the given instance, returning the top `k`
      most influential train instances with their scores.
  
      !!! Note
          Test instances should have `targets` so that a loss can be computed.
      """
      return self.interpret_instances([test_instance], k=k)[0]
  
imports: import logging
  from os import PathLike
  import re
  from typing import List, Optional, NamedTuple, Sequence, Union, Dict, Any
  import torch
  from torch import autograd
  from allennlp.common import Registrable, Lazy, plugins
  from allennlp.common.tqdm import Tqdm
  from allennlp.common.util import int_to_device
  from allennlp.data import Instance, DatasetReader, DatasetReaderInput, Batch
  from allennlp.data.data_loaders import DataLoader, SimpleDataLoader
  from allennlp.models import Model, Archive, load_archive
  from allennlp.nn.util import move_to_device
label_desc: Use image node_id 7 for calling the InfluenceInterpreter obj's underlying member method code with example usage: obj.interpret(test_instance, k) and returns: self