class_docstr: TextTemplateInput is an implementation of InterpretableInput for text inputs, whose
  interpretable features are certain segments (e.g., words, phrases) of the text.
  It takes a template string (or function) to define the feature segmentats
  of the input text. Its input format to the model will be the completed text,
  while its interpretable representation will be a binary tensor of the number of
  the segment features whose values indicates if the feature is
  “presence” or “absence”.
  
  Args:
  
      template (str or Callable): template string or function that takes
              the text segments and format them into the text input for the model
      values (List[str] or Dict[str, str]): the values of the segments. it is
              the input to the template.
      baselines (List[str] or Dict[str, str] or Callable or None, optional): the
              baseline values for the segment features. If it is None, emptry string
              will be used as the baseline.
              Default: None
      mask (List[int] or Dict[str, int] or None, optional): the mask to group the
              segment features. It must be in the same format as the values
              and assign each segment a mask index. Segments with the same
              index will be seen as a single interpretable feature, which means
              they must be perturbed together and end with same attributions.
              Default: None
  
  Examples::
  
      >>> text_inp = TextTemplateInput(
      >>>     template="{} feels {} right now",
      >>>     values=["He", "depressed"],
      >>>     baselines=["It", "neutral"],
      >>> )
      >>>
      >>> text_inp.to_tensor()
      >>> # torch.tensor([[1, 1]])
      >>>
      >>> text_inp.to_model_input(torch.tensor([[0, 1]]))
      >>> # "It feels depressed right now"
class_docstr_tok: ["TextTemplateInput","is","an","implementation","of","InterpretableInput","for","text","inputs",",","whose","interpretable","features","are","certain","segments","(","e.g.",",","words",",","phrases",")","of","the","text",".","It","takes","a","template","string","(","or","function",")","to","define","the","feature","segmentats","of","the","input","text",".","Its","input","format","to","the","model","will","be","the","completed","text",",","while","its","interpretable","representation","will","be","a","binary","tensor","of","the","number","of","the","segment","features","whose","values","indicates","if","the","feature","is","\u201c","presence","\u201d","or","\u201c","absence","\u201d",".","Args",":","template","(","str","or","Callable",")",":","template","string","or","function","that","takes","the","text","segments","and","format","them","into","the","text","input","for","the","model","values","(","List","[","str","]","or","Dict","[","str",",","str","]",")",":","the","values","of","the","segments",".","it","is","the","input","to","the","template",".","baselines","(","List","[","str","]","or","Dict","[","str",",","str","]","or","Callable","or","None",",","optional",")",":","the","baseline","values","for","the","segment","features",".","If","it","is","None",",","emptry","string","will","be","used","as","the","baseline",".","Default",":","None","mask","(","List","[","int","]","or","Dict","[","str",",","int","]","or","None",",","optional",")",":","the","mask","to","group","the","segment","features",".","It","must","be","in","the","same","format","as","the","values","and","assign","each","segment","a","mask","index",".","Segments","with","the","same","index","will","be","seen","as","a","single","interpretable","feature",",","which","means","they","must","be","perturbed","together","and","end","with","same","attributions",".","Default",":","None","Examples",":",":",">",">",">","text_inp","=","TextTemplateInput","(",">",">",">","template=","''","{","}","feels","{","}","right","now","''",",",">",">",">","values=","[","``","He","''",",","``","depressed","''","]",",",">",">",">","baselines=","[","``","It","''",",","``","neutral","''","]",",",">",">",">",")",">",">",">",">",">",">","text_inp.to_tensor","(",")",">",">",">","#","torch.tensor","(","[","[","1",",","1","]","]",")",">",">",">",">",">",">","text_inp.to_model_input","(","torch.tensor","(","[","[","0",",","1","]","]",")",")",">",">",">","#","``","It","feels","depressed","right","now","''"]
code: def to_tensor(self) -> torch.Tensor:
      # Interpretable representation in shape(1, n_itp_features)
      return torch.tensor([[1.0] * self.n_itp_features])
  
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 2 for calling the TextTemplateInput obj's underlying member method code with example usage: obj.to_tensor() and returns: torch