class_docstr: An abstract class to define a nearest neighbors data structure. Classes
  implementing this interface are intended for computing proponents / opponents in
  certain implementations of `TracInCPBase`. In particular, it is for use in
  implementations which compute proponents / opponents of a test instance by
  1) storing representations of training instances within a nearest neighbors data
  structure, and 2) finding within that structure the nearest neighbor of the
  representation of a test instance. The assumption is that the data structure
  stores the tensors passed to the `setup` method, which we refer to as the "stored
  tensors". If this class is used to find proponents / opponents, the nearest
  neighbors of a tensor should be the stored tensors that have the largest
  dot-product with the query.
class_docstr_tok: ["An","abstract","class","to","define","a","nearest","neighbors","data","structure",".","Classes","implementing","this","interface","are","intended","for","computing","proponents","\/","opponents","in","certain","implementations","of","`","TracInCPBase","`",".","In","particular",",","it","is","for","use","in","implementations","which","compute","proponents","\/","opponents","of","a","test","instance","by","1",")","storing","representations","of","training","instances","within","a","nearest","neighbors","data","structure",",","and","2",")","finding","within","that","structure","the","nearest","neighbor","of","the","representation","of","a","test","instance",".","The","assumption","is","that","the","data","structure","stores","the","tensors","passed","to","the","`","setup","`","method",",","which","we","refer","to","as","the","``","stored","tensors","''",".","If","this","class","is","used","to","find","proponents","\/","opponents",",","the","nearest","neighbors","of","a","tensor","should","be","the","stored","tensors","that","have","the","largest","dot-product","with","the","query","."]
docstr: `data` denotes the "stored tensors". These are the tensors within which we
  want to find the nearest neighbors to each tensor in a batch of tensors, via a
  call to the`get_nearest_neighbors` method. Before we can call it, however,
  we need to first store the stored tensors, by doing processing that indexes
  the stored tensors in a form that enables nearest-neighbors computation.
  This method does that preprocessing, and is assumed to be called before any
  call to `get_nearest_neighbors`. For example, this method might put the
  stored tensors in a K-d tree. The tensors in the "stored tensors" can be of a
  common, but arbitrary shape, denoted *, so that `data` is of shape (N, *),
  where N is the number of tensors in the stored tensors. Therefore, the 0-th
  dimension indexes the tensors in the stored tensors.
  
  Args:
      data (Tensor): A tensor of shape (N, *) representing the stored tensors.
              The 0-th dimension indexes the tensors in the stored tensors,
              so that `data[i]` is the tensor with index `i`. The nearest
              neighbors of a query will be referred to by their index.
docstr_tok: ["`","data","`","denotes","the","``","stored","tensors","''",".","These","are","the","tensors","within","which","we","want","to","find","the","nearest","neighbors","to","each","tensor","in","a","batch","of","tensors",",","via","a","call","to","the","`","get_nearest_neighbors","`","method",".","Before","we","can","call","it",",","however",",","we","need","to","first","store","the","stored","tensors",",","by","doing","processing","that","indexes","the","stored","tensors","in","a","form","that","enables","nearest-neighbors","computation",".","This","method","does","that","preprocessing",",","and","is","assumed","to","be","called","before","any","call","to","`","get_nearest_neighbors","`",".","For","example",",","this","method","might","put","the","stored","tensors","in","a","K-d","tree",".","The","tensors","in","the","``","stored","tensors","''","can","be","of","a","common",",","but","arbitrary","shape",",","denoted","*",",","so","that","`","data","`","is","of","shape","(","N",",","*",")",",","where","N","is","the","number","of","tensors","in","the","stored","tensors",".","Therefore",",","the","0-th","dimension","indexes","the","tensors","in","the","stored","tensors",".","Args",":","data","(","Tensor",")",":","A","tensor","of","shape","(","N",",","*",")","representing","the","stored","tensors",".","The","0-th","dimension","indexes","the","tensors","in","the","stored","tensors",",","so","that","`","data","[","i","]","`","is","the","tensor","with","index","`","i","`",".","The","nearest","neighbors","of","a","query","will","be","referred","to","by","their","index","."]
code: def setup(self, data: torch.Tensor) -> None:
      r"""
      `data` denotes the "stored tensors". These are the tensors within which we
      want to find the nearest neighbors to each tensor in a batch of tensors, via a
      call to the`get_nearest_neighbors` method. Before we can call it, however,
      we need to first store the stored tensors, by doing processing that indexes
      the stored tensors in a form that enables nearest-neighbors computation.
      This method does that preprocessing, and is assumed to be called before any
      call to `get_nearest_neighbors`. For example, this method might put the
      stored tensors in a K-d tree. The tensors in the "stored tensors" can be of a
      common, but arbitrary shape, denoted *, so that `data` is of shape (N, *),
      where N is the number of tensors in the stored tensors. Therefore, the 0-th
      dimension indexes the tensors in the stored tensors.
  
      Args:
          data (Tensor): A tensor of shape (N, *) representing the stored tensors.
                  The 0-th dimension indexes the tensors in the stored tensors,
                  so that `data[i]` is the tensor with index `i`. The nearest
                  neighbors of a query will be referred to by their index.
      """
      pass
  
file_path: captum/captum/influence/_utils/nearest_neighbors.py
imports: from abc import ABC, abstractmethod
  from typing import Tuple
  import torch
  from torch import Tensor
label_desc: Use image node_id 2 for calling the NearestNeighbors obj's underlying member method code with example usage: obj.setup(data) without return types