class_docstr: TextFeature is used to visualize text (e.g. sentences) in Insights.
  It expects the visualization transform to convert the input data (e.g. index to
  string) to the raw text.
class_docstr_tok: ["TextFeature","is","used","to","visualize","text","(","e.g",".","sentences",")","in","Insights",".","It","expects","the","visualization","transform","to","convert","the","input","data","(","e.g",".","index","to","string",")","to","the","raw","text","."]
code: def visualize(
      self, attribution, data, contribution_frac
  ) -> FeatureOutput:
      if self.visualization_transform:
          text = self.visualization_transform(data)
      else:
          text = data
  
      attribution = attribution.squeeze(0)
      data = data.squeeze(0)
      if len(attribution.shape) > 1:
          attribution = attribution.sum(dim=1)
  
      # L-Infinity norm, if norm is 0, all attr elements are 0
      attr_max = attribution.abs().max()
      normalized_attribution = safe_div(attribution, attr_max)
  
      modified = [x * 100 for x in normalized_attribution.tolist()]
      return FeatureOutput(
          name=self.name,
          base=text,
          modified=modified,
          type=self.visualization_type(),
          contribution=contribution_frac,
      )
  
imports: import base64
  import warnings
  from collections import namedtuple
  from io import BytesIO
  from typing import Callable, List, Optional, Union
  from captum._utils.common import safe_div
  from captum.attr._utils import visualization
  from captum.insights.attr_vis._utils.transforms import format_transforms
label_desc: Use image node_id 3 for calling the TextFeature obj's underlying member method code with example usage: obj.visualize(attribution, data, contribution_frac) and returns: FeatureOutput