class_docstr: InterpretableInput is an adapter for different kinds of model inputs to
  work in Captum's attribution methods. Generally, attribution methods of Captum
  assume the inputs are numerical PyTorch tensors whose 1st dimension must be batch
  size and each index in the rest of dimensions is an interpretable feature. But this
  is not always true in practice. First, the model may take inputs of formats other
  than tensor that also require attributions. For example, a model with encapsulated
  tokenizer can directly take string as input. Second, what is considered as
  an interpretable feature always depends on the actual application and the user's
  desire. For example, the interpretable feature of an image tensor can either be
  each pixel or some segments. For text, users may see the entire string as one
  interpretable feature or view each word as one interpretable feature. This class
  provides a place to define what is the actual model input and the corresponding
  interpretable format for attribution, and the transformation between them.
  It serves as a common interface to be used inthe attribution methods to make
  Captum understand how to perturb various inputs.
  
  The concept Interpretable Input mainly comes from the following two papers:
  
  `"Why Should I Trust You?": Explaining the Predictions of Any Classifier
  <https://arxiv.org/abs/1602.04938>`_
  
  `A Unified Approach to Interpreting Model Predictions
  <https://arxiv.org/abs/1705.07874>`_
  
  which is also referred to as interpretable representation or simplified
  input. It can be represented as a mapping function:
  
  .. math::
      x = h_x(x')
  
  where :math:`x` is the model input, which can be anything that the model consumes;
  :math:`x'` is the interpretable input used in the attribution algorithms
  (it must be a PyTorch tensor in Captum), which is often
  binary indicating the “presence” or “absence”; :math:`h_x` is the
  transformer. It is supposed to work with perturbation-based attribution methods,
  but if :math:`h_x` is differentiable, it may also be used
  in gradient-based methods.
  
  InterpretableInput is the abstract class defining the interface. Captum provides
  the child implementations for some common input formats,
  like text and sparse features. Users can inherit this
  class to create other types of customized input.
  
  (We expect to support InterpretableInput in all attribution methods, but it
  is only allowed in certain attribution classes like LLMAttribution for now.)
class_docstr_tok: ["InterpretableInput","is","an","adapter","for","different","kinds","of","model","inputs","to","work","in","Captum","'s","attribution","methods",".","Generally",",","attribution","methods","of","Captum","assume","the","inputs","are","numerical","PyTorch","tensors","whose","1st","dimension","must","be","batch","size","and","each","index","in","the","rest","of","dimensions","is","an","interpretable","feature",".","But","this","is","not","always","true","in","practice",".","First",",","the","model","may","take","inputs","of","formats","other","than","tensor","that","also","require","attributions",".","For","example",",","a","model","with","encapsulated","tokenizer","can","directly","take","string","as","input",".","Second",",","what","is","considered","as","an","interpretable","feature","always","depends","on","the","actual","application","and","the","user's","desire",".","For","example",",","the","interpretable","feature","of","an","image","tensor","can","either","be","each","pixel","or","some","segments",".","For","text",",","users","may","see","the","entire","string","as","one","interpretable","feature","or","view","each","word","as","one","interpretable","feature",".","This","class","provides","a","place","to","define","what","is","the","actual","model","input","and","the","corresponding","interpretable","format","for","attribution",",","and","the","transformation","between","them",".","It","serves","as","a","common","interface","to","be","used","inthe","attribution","methods","to","make","Captum","understand","how","to","perturb","various","inputs",".","The","concept","Interpretable","Input","mainly","comes","from","the","following","two","papers",":","`","``","Why","Should","I","Trust","You","?","``",":","Explaining","the","Predictions","of","Any","Classifier","<","https",":","\/\/arxiv.org\/abs\/1602.04938",">","`","_","`","A","Unified","Approach","to","Interpreting","Model","Predictions","<","https",":","\/\/arxiv.org\/abs\/1705.07874",">","`","_","which","is","also","referred","to","as","interpretable","representation","or","simplified","input",".","It","can","be","represented","as","a","mapping","function",":","..","math",":",":","x","=","h_x","(","x","'",")","where",":","math",":","`","x","`","is","the","model","input",",","which","can","be","anything","that","the","model","consumes",";",":","math",":","`","x","'","`","is","the","interpretable","input","used","in","the","attribution","algorithms","(","it","must","be","a","PyTorch","tensor","in","Captum",")",",","which","is","often","binary","indicating","the","\u201c","presence","\u201d","or","\u201c","absence","\u201d",";",":","math",":","`","h_x","`","is","the","transformer",".","It","is","supposed","to","work","with","perturbation-based","attribution","methods",",","but","if",":","math",":","`","h_x","`","is","differentiable",",","it","may","also","be","used","in","gradient-based","methods",".","InterpretableInput","is","the","abstract","class","defining","the","interface",".","Captum","provides","the","child","implementations","for","some","common","input","formats",",","like","text","and","sparse","features",".","Users","can","inherit","this","class","to","create","other","types","of","customized","input",".","(","We","expect","to","support","InterpretableInput","in","all","attribution","methods",",","but","it","is","only","allowed","in","certain","attribution","classes","like","LLMAttribution","for","now",".",")"]
docstr: Return the interpretable representation of this input as a tensor
  
  Returns:
  
      itp_tensor (Tensor): interpretable tensor
docstr_tok: ["Return","the","interpretable","representation","of","this","input","as","a","tensor","Returns",":","itp_tensor","(","Tensor",")",":","interpretable","tensor"]
code: def to_tensor(self) -> Tensor:
      """
      Return the interpretable representation of this input as a tensor
  
      Returns:
  
          itp_tensor (Tensor): interpretable tensor
      """
      pass
  
file_path: captum/captum/attr/_utils/interpretable_input.py
imports: from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  from torch import Tensor
label_desc: Use image node_id 1 for calling the InterpretableInput obj's underlying member method code with example usage: obj.to_tensor() without return types